Viewer status (a document opened?)

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange

relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Viewer status (a document opened?)

Post by relapse »

Hello!

A new question: how can I determine, whether a PDF document is opened in the Viewer (with the OpenDocument method) or not?



Thanks!!!
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Viewer status (a document opened?)

Post by Stefan - PDF-XChange »

Hello relapse,

You can obtain the file name for any open document via one of the three ways below (in pseudocode):

Code: Select all

...
DoVerb("Documents[#4095].FileName", "get", DataIn, DataOut, 0);
// or:
GetProperty("Documents[#4095].FileName", DataOut, 0);
// or:
GetDocumentProperty(4095, "FileName", DataOut, 0);
...
where 4095 is an example of an unique document ID

And compare it with the file you are planning to open.

The default action for the Viewer if a file is already open in it is to just set that document as the active one (if more than one document is displayed in tabs and this document is not currently the active one).

Best,
Stefan
relapse
User
Posts: 167
Joined: Wed Jan 18, 2012 11:10 am

Re: Viewer status (a document opened?)

Post by relapse »

Sorry, I haven't formulated my question precisely enough:

I properly wanted to know how I can find out, whether ANY document is opened at all. I solved this issue with the GetActiveDocument() function (C# example):

Code: Select all

                int currentDocId;
                pdfViewer.GetActiveDocument(out currentDocId);

                if (currentDocId > 0)
                {
                    pdfViewer.CloseDocument(_documentId, (int) PDFXCviewAxLib.PXCVA_Flags.PXCVA_NoUI);
                }
                pdfViewer.OpenDocument(_tempFile, string.Empty, out _documentId, 0);
If no document is active, you get a negative value via the out parameter!


Thanks for your reply!
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19913
Joined: Mon Jan 12, 2009 8:07 am

Re: Viewer status (a document opened?)

Post by Stefan - PDF-XChange »

Hi Relapse,

You are welcome and glad that you found your solution!

Cheers,
Stefan