RTTSoftware Support Forum

PDF Explorer => General => Topic started by: Padanges on September 02, 2016, 01:00:21 PM

Title: Using Custom Scripts with PDF View mode
Post by: Padanges 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
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT on September 04, 2016, 12:51:53 AM
No. Please give me a workflow example that needs this.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges 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?
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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  :)
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 06, 2016, 06:40:58 AM
Do you consider it making a new feature for the next release? :)
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 07, 2016, 11:14:33 AM
Could you make it possible to send the "open in Images mode" command as well?
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 09, 2016, 09:58:37 PM
OK. This will be helpful, once the code will be implemented.
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges 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)
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges 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?
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT 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 (http://www.rttsoftware.com/Manuals/Index.htm?pageURL=PDFE/English/WebInterface.htm#thumbnails)). The advanced web interface client installer (http://www.rttsoftware.com/forum.php?dsturl=http%3A%2F%2Fwww.rttsoftware.com%2Fforum%2Findex.php%3Ftopic%3D322) 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.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 15, 2016, 08:03:22 PM
Quote
and that's what will be used by default, in the new version, to handle any other file type
You mean the new version of the web interface?
Current PDFe document handling is fine - Sumatra as a internal viewer covers all the most popular file types. To start fully appreciating it we only need to get more file types listed in the grid.
The thumbnail idea for PDFe is a different topic though. We will need to collaborate on this later.

Quote
For your scenario it's probably better to, a least, add the file reference to the grid.
But what if I want only to open a temporary document? For example, that which shows the resulting document but, for a better preview, as a handout, or as a report log? Do I really must to include it to the grid just to have it removed (manually?) after checking it? This seems too restricting.
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT on September 16, 2016, 04:04:57 PM
Quote
and that's what will be used by default, in the new version, to handle any other file type
You mean the new version of the web interface?
Yes.
Quote
Current PDFe document handling is fine - Sumatra as a internal viewer covers all the most popular file types. To start fully appreciating it we only need to get more file types listed in the grid.
And I'm going to add support to specify more plugins. It will be able to handle view any file type, as long there is a lister or npapi plugin available.

Quote
Do I really must to include it to the grid just to have it removed (manually?) after checking it? This seems too restricting.
I've now set the host OpenFile command to open it even if not in the grid.
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 16, 2016, 05:34:59 PM
Great, that's what I needed ;D now the last thing about different pdfe modes: how much can we mess with Images mode? I want to test out an idea where after generating a report document I can open it, let's say, in Images mode. But to see images being extracted each time I open that same file (even if the file has not been modified), or to be forced to wait for it to finish this task is not really serious. Can we save cache for a selected file for Images mode? How can we escape unnecessary loading times?
Title: Re: Using Custom Scripts with PDF View mode
Post by: Padanges on September 16, 2016, 09:29:55 PM
Quote
I've now set the host OpenFile command to open it even if not in the grid.
Will there be a possibility to get Opened File Name? If we activate PDF View mode from a PDF View with files selected we get opened the last file active (by the highlight) even if that file is not in current file selection list. After running a custom script with a hotkey we can't know the opened file File name just by taking first (was this "selection down" or "selection up") entry in this situation, we need either to get specifically Opened File Filename or at least the Last Selected (that which is under the current highlight) Filename.
Title: Re: Using Custom Scripts with PDF View mode
Post by: RTT on September 18, 2016, 11:25:18 PM
Why not make the report in PDF format? You can easily merge the images with the IDocumentMerger object (http://www.rttsoftware.com/Manuals/Index.htm?pageURL=PDFE/English/MyScriptsAPI.htm#IDocumentMerger).