Author Topic: Using Custom Scripts with PDF View mode  (Read 1847 times)

0 Members and 1 Guest are viewing this topic.

Padanges

  • Newbie
  • *
  • Posts: 179
Using Custom Scripts with PDF View mode
« on: September 02, 2016, 01:00:21 PM »
Hi,
can we use scripts to get current PDF View mode (or Images Mode tab) open a file? At a specific page number? When internal viewer is sLister application? Can we send commands (using custom scripts) for PDF View application? Especially to sLister?


Thanks in advance

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #1 on: September 04, 2016, 12:51:53 AM »
No. Please give me a workflow example that needs this.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #2 on: September 04, 2016, 08:36:04 AM »
I was thinking about running a script which after some calculations would choose the "best match" document and automatically open it in PDF View mode. The additional question was would it be possible to open it at a specific page automatically.

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #3 on: September 05, 2016, 12:25:39 AM »
Interesting! I will look into it. And extending the idea to be able to select files in the grid opens the possibility to use scripts to automate filter operations.

Regarding the opening of the reader at a specific page. Some of the supported reader interfaces have this possibility, but I don't see how to do it with the lister plugins, and the slister in particular. The SumatraPDF, automated by the slister, supports a command line -page #pagenum parameter, but the slister plugin disables this possibility by enclosing the entire FileToLoad parameter, of the ListLoad function, in double quotes.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #4 on: September 05, 2016, 08:07:01 AM »
Thanks for the answer. So, perhaps, we can at least open a selected entry in PDF View mode, if not opening at a specific page? Could you give a code sample?

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #5 on: September 06, 2016, 01:33:15 AM »
Technically possible to do it internally. Still not possible to do it from a script. I still need to implement the send command to host thing  :)

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #6 on: September 06, 2016, 06:40:58 AM »
Do you consider it making a new feature for the next release? :)

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #7 on: September 07, 2016, 11:14:33 AM »
Could you make it possible to send the "open in Images mode" command as well?

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #8 on: September 08, 2016, 11:59:59 PM »
I've now implemented a SendHostCommand method and some commands.
Here's some dumb test code, so you can get the idea how it will work.
Code: [Select]
function SelectFilesHostCmd() {
    this.Command = 'GridSelectFiles';
    this.Files = [];
    this.toString = function() {
        return JSON.stringify(this);
    }
};

function UnselectAllHostCmd() {
    this.Command = 'GridUnselectAll';
    this.toString = function() {
        return JSON.stringify(this);
    }
}

function OpenFileHostCmd() {
    this.Command = 'OpenFile';
    this.Filename = '';
    this.Mode = 0; //QuickPDFView=0,QuickPDFEdit=1,OnGridPreview=2,ViewImages=3,ExternalApp=4
    this.toString = function() {
        return JSON.stringify(this);
    }
}

UnselectAll = new UnselectAllHostCmd;
pdfe.sendhostcommand(UnselectAll);

var SelectFilesCmd = new SelectFilesHostCmd();
for (var i = 0; i < pdfe.SelectedFiles.Count; i += 2) {
    SelectFilesCmd.Files.push(pdfe.SelectedFiles(i).filename);
}

if (SelectFilesCmd.Files.length > 0) {
    var n = pdfe.sendhostcommand(SelectFilesCmd);
    if (n != SelectFilesCmd.Files.length) pdfe.echo('some not selected');
}

var OpenFileCmd = new OpenFileHostCmd;
for (var i = 0; i < pdfe.SelectedFiles.Count; i++) {
    var file = pdfe.SelectedFiles(i);
    if (file.filename.indexOf('moby') > 0) {
        OpenFileCmd.Filename = file.filename;
        OpenFileCmd.Mode = 0;
        pdfe.sendhostcommand(OpenFileCmd);
        pdfe.alert('Next');
        OpenFileCmd.Mode = 1;
        pdfe.sendhostcommand(OpenFileCmd);
        pdfe.alert('Next');
        OpenFileCmd.Mode = 2;
        pdfe.sendhostcommand(OpenFileCmd);
        pdfe.alert('Next');
        OpenFileCmd.Mode = 3;
        pdfe.sendhostcommand(OpenFileCmd);
        pdfe.alert('Next');
        OpenFileCmd.Mode = 4;
        pdfe.sendhostcommand(OpenFileCmd);
        break;
    }
}
Let me know about other commands you think will be useful.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #9 on: September 09, 2016, 09:58:37 PM »
OK. This will be helpful, once the code will be implemented.

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #10 on: September 10, 2016, 12:23:18 AM »
The above code is already implemented in my development version. Just asking for what other commands you think will be useful.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #11 on: September 10, 2016, 07:24:31 AM »
While exploring ideas I've stumbled upon questions:
1) how to open any file (not only in a grid) in a View/Images mode; I guess that's already implemented
2) how to get the name of the file which is currently open in a View/Images mode
3) how to save images cache for a selected file for Images mode (to save load time, if file has not been modified)

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #12 on: September 13, 2016, 12:49:23 AM »
While exploring ideas I've stumbled upon questions:
1) how to open any file (not only in a grid) in a View/Images mode; I guess that's already implemented
Not implemented. The file would need to be indexed and added to the grid. Something to look at...
Quote
2) how to get the name of the file which is currently open in a View/Images mode
This usually corresponds to the grid active row file, so a command to get it should do the job.

Quote
3) how to save images cache for a selected file for Images mode (to save load time, if file has not been modified)
This is really not needed, for this specific extract images tool.
The web interface already has this to handle the documents first page thumbnails. If eventually a future version adds thumbnails view to the GUI, it will use the same technique/cached files.

Padanges

  • Newbie
  • *
  • Posts: 179
Re: Using Custom Scripts with PDF View mode
« Reply #13 on: September 13, 2016, 09:08:07 AM »
Quote
Not implemented. The file would need to be indexed and added to the grid.
I guess to open a file with an internal viewer you need to send a file path to it (perhaps the same is with Images mode too), then why this file path can't be for an unindexed file?

Quote
The web interface already has this to handle the documents first page thumbnails.
I installed PDFe with web interface disabled. Can you get a first page thumbnail for any file type (which can be supported for exaple with SumatraPDF) or just a PDF file with web interface?

RTT

  • Administrator
  • *****
  • Posts: 775
Re: Using Custom Scripts with PDF View mode
« Reply #14 on: September 15, 2016, 05:46:27 PM »
Quote
Not implemented. The file would need to be indexed and added to the grid.
I guess to open a file with an internal viewer you need to send a file path to it (perhaps the same is with Images mode too), then why this file path can't be for an unindexed file?
Yes, but then the Grid, InfoEdit tool, and any other GUI element that is showing information about the selected file, will be desynchronized with what's open in the viewer. It's already possible to have this situation, by changing from the PDFView to the grid PDFInfo view, select a different row and get back to the PDFView while pressing the CTRL key. But in this case it's a user choice, so he knows what's going on. For your schenario it's probably better to, a least, add the file reference to the grid.

Quote
Quote
The web interface already has this to handle the documents first page thumbnails.
I installed PDFe with web interface disabled. Can you get a first page thumbnail for any file type (which can be supported for exaple with SumatraPDF) or just a PDF file with web interface?
The web interface can use external renders, or the shell installed thumbnail handlers, to create the thumbnails (see here). The advanced web interface client installer configures the web interface to produce the thumbnails using an included external render (after installed, check the folder C:\MySite\utils), that generates PDF and CHM thumbnails.
Having it configured to use the shell thumbnail handler will enable thumbnails for any file type with a installed thumbnail handler, and that's what will be used by default, in the new version, to handle any other file type.