Bug? in getDocumentProperty

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

abc123abc123
User
Posts: 35
Joined: Mon Oct 17, 2011 2:36 pm

Bug? in getDocumentProperty

Post by abc123abc123 »

I do this:
object CurrentPage;
_PdfViewer.GetDocumentProperty(4095 , "Pages.Current",out CurrentPage, 0);

with nearly all pages this works great.
My Document has for example 415 pages. When I´m on page 15 he says CurrenPage=15. Same on page 100: CurrentPage=100.
But when I am on page 415(last page) he says: CurrentPage=414(lastpage -1).

Is there already a solution for this problem



Edit:
When I open the first document, close this and open then a new document i get an comexception. ( {"Ausnahme von HRESULT: 0x82130001"})
bei PDFXCviewAxLib.IPDFXCview2.GetDocumentProperty(Int32 ID, String Name, Object& DataOut, Int32 Flags)
bei AxPDFXCviewAxLib.AxCoPDFXCview.GetDocumentProperty(Int32 iD, String name, Object& dataOut, Int32 flags)
bei HomagGroup.PdfView.MainWindowViewModel.CheckButtonState() in C:\Users\dh10hah\Documents\Visual Studio 2010\TFS\000_Standardapplikationen_DL\000_AddOns\Main\HomagGroup\PdfView\MainWindowViewModel.cs:Zeile 412.
Last edited by abc123abc123 on Fri Nov 04, 2011 11:59 am, edited 2 times in total.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Bug? in getDocumentProperty

Post by Vasyl - PDF-XChange »

Hi, abc123abc123.

Note: the document's property "Pages.Current" contains the zero-based index of page...
So, if you see the last page as current then "Pages.Current" should contain the (<PagesCount> - 1).
and if you see the first page as current - "Pages.Current" == 0.

So:
"Pages.Current" == (<DisplayedCurrentPageIndex> - 1)

Best
Regards.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
abc123abc123
User
Posts: 35
Joined: Mon Oct 17, 2011 2:36 pm

Re: Bug? in getDocumentProperty

Post by abc123abc123 »

Oh your right i looked on the wrong part of my code. Sorry

But the 2nd problem in my post still exists. Have you any idea?
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Bug? in getDocumentProperty

Post by Vasyl - PDF-XChange »

The 'current page' in our viewer-control (and in Adobe Acrobat) is the page which is under center-point of pages-view window...
In some cases this rule can give some strange result, especially when zoom is small(<50%) and enabled 'continuous' pages-layout.
Check these moments please...

Also you may give us the detailed, step-by-step instruction - how to reproduce the wrong behavior (the zoom-level, zoom-mode, pages-layout are important).
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
abc123abc123
User
Posts: 35
Joined: Mon Oct 17, 2011 2:36 pm

Re: Bug? in getDocumentProperty

Post by abc123abc123 »

Here is the .dat file with the settings i use. The menuebar is also disabled.
You do not have the required permissions to view the files attached to this post.
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Bug? in getDocumentProperty

Post by Vasyl - PDF-XChange »

When I open the first document, close this and open then a new document i get an comexception. ( {"Ausnahme von HRESULT: 0x82130001"})
bei PDFXCviewAxLib.IPDFXCview2.GetDocumentProperty(Int32 ID, String Name, Object& DataOut, Int32 Flags)
bei AxPDFXCviewAxLib.AxCoPDFXCview.GetDocumentProperty(Int32 iD, String name, Object& dataOut, Int32 flags)
Could you please give us the exact code that you are using that throws this exception for testing?
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
abc123abc123
User
Posts: 35
Joined: Mon Oct 17, 2011 2:36 pm

Re: Bug? in getDocumentProperty

Post by abc123abc123 »

In the underlined Line i get the com exception.

I can open a document and than do this as often as i want in this document. When i open the next document and then do this i get an comexception.

Code: Select all

public void CheckButtonState()        
        {
            if (_DocumentOpened)
            {  //Every Page and Document Opened
                ZoomInEnabled = true;
                ZoomOutEnabled = true;
                FitPageEnabled = true;
                FitWidthEnabled = true;
                PrintEnabled = true;
                ToggleBookmarksEnabled = true;

                object CurrentPage;
               [u][b] _PdfViewer.GetDocumentProperty(4095 , "Pages.Current",out CurrentPage, 0);//looks for the current page[/b][/u]
                if (String.Compare("0", Convert.ToString(CurrentPage), true) == 0)
                {  //First Page
                    PreviousPageEnabled = false;
                    FirstPageEnabled = false;
                    NextPageEnabled = true;
                }
                else
                {  //Not First Page
                    FirstPageEnabled = true;
                    PreviousPageEnabled = true;
                    object LastPage;
                    _PdfViewer.GetDocumentProperty(4095, "Pages.Count", out LastPage, 0);//looks for the last page
                    LastPage = Convert.ToString(Convert.ToInt32(LastPage) -1);//Currentpage is zerobased
                    if (String.Compare(Convert.ToString(LastPage), Convert.ToString(CurrentPage), true) == 0)
                    {  //Last Page
                        NextPageEnabled = false;
                    }
                    else
                    {   //Not Last Page                        
                        NextPageEnabled = true;
                    }
                }
            }
            else
            {   //No Document Opened
                FirstPageEnabled = false;
                NextPageEnabled = false;
                PreviousPageEnabled = false;
                ZoomInEnabled = false;
                ZoomOutEnabled = false;
                FitPageEnabled = false;
                FitWidthEnabled = false;
                PrintEnabled = false;
                ToggleBookmarksEnabled = false;
            }
        }
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: Bug? in getDocumentProperty

Post by Vasyl - PDF-XChange »

I think the reason of your problem is that you use the definite number for document ID.
_PdfViewer.GetDocumentProperty(4095, "Pages.Current",out CurrentPage, 0);

It's incorrect - you must keep the docId from each 'OpenDocument' and use it later... So, the correct code should be:

int docId;
pdfViewer.OpenDocument(<FileName>, ..., out docId, 0);
....
....
pdfViewer.GetDocumentProperty(docId, "Pages.Current", out CurrentPage, 0);

HTH.
PDF-XChange Co. LTD (Project Developer)

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.