Error with pageNum

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

HeikoH22
User
Posts: 6
Joined: Tue Jul 14, 2009 10:06 am

Error with pageNum

Post by HeikoH22 »

Hello,

I had updated from V 1.x up to V2.0 (Build 42.2).
Now there is a problem with reading the page numbers correctly. There is only “0” displayed.
What can we do to solve this problem?

Code: Select all

    'Alle Bookmarks werden ausgelesen
    jsCode = "function DumpBookmark(bkm, nLevel)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "var s = '';"
    jsCode = jsCode & "for (var i = 0; i < nLevel; i++) s += ' ';"
    jsCode = jsCode & "s += '+-';"
    jsCode = jsCode & "bkm.execute(this.gotoNamedDest(bkm.name));"
    jsCode = jsCode & "s += bkm.name;"
    jsCode = jsCode & "s += '=====' + this.pageNum;"
    jsCode = jsCode & "s += '\n';"
    jsCode = jsCode & "if (bkm.children != null)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "for (var i = 0; i < bkm.children.length; i++)"
    jsCode = jsCode & "s += DumpBookmark(bkm.children[i], nLevel + 1);"
    jsCode = jsCode & "}"
    jsCode = jsCode & "return s;"
    jsCode = jsCode & "}"
    jsCode = jsCode & "DumpBookmark(this.bookmarkRoot, 0);"

Best regards


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

Re: Error with pageNum

Post by Stefan - PDF-XChange »

Hello Heiko,

I think it's because of the gotoNamedDest function.
Please see this one (from the Adobe JS API reference), it worked for me, just the text output is in the console:

Code: Select all

function DumpBookmark(bkm, nLevel)
{
  var s = "";
  for (var i = 0; i < nLevel; i++) s += " ";
  console.println(s + "+-" + bkm.name);
  if (bkm.children != null)
  for (var i = 0; i < bkm.children.length; i++) 
  DumpBookmark(bkm.children[i], nLevel + 1); 
} 
console.clear(); console.show();
console.println("Dumping all bookmarks in the document.");

DumpBookmark(this.bookmarkRoot, 0);
Best Regards,
Stefan
HeikoH22
User
Posts: 6
Joined: Tue Jul 14, 2009 10:06 am

Re: Error with pageNum

Post by HeikoH22 »

Hello,

the problem persists.
I tried to solve the problem by presenting it in different discussion fora, unfortunately without success.
Some time ago I had the same problem. In that case it was solved by updating the components of the "PDF xChange Viewer".

Best regards


Heiko
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2449
Joined: Thu Jun 30, 2005 4:11 pm

Re: Error with pageNum

Post by Vasyl - PDF-XChange »

Here is the real problem. It will be fixed in the next build.
1. Temporary workaround, please display bookmarks pane before bookmarks enumeration.
2. Small fix for your code:
replace:

Code: Select all

bkm.execute(this.gotoNamedDest(bkm.name));
to:

Code: Select all

bkm.execute();
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.
HeikoH22
User
Posts: 6
Joined: Tue Jul 14, 2009 10:06 am

Re: Error with pageNum

Post by HeikoH22 »

Hello,

I downloaded the mostrecent update of the pdf-component. However, the problem stillconsists.

At first, I displayed the navigation and then Iread-out the pages.

I adapted the code according to yourexplanation. However, there remain some problems to be solved.

1. Has the pdf-component to be in the visible area in order toread-out the page numbers?
2. The read-out page numbers of the bookmarks sometimes do not coincidewith the real page numbers.

Will this problem be solved in the next update? If so, when will thatcome out?


Best regards


Heiko
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Error with pageNum

Post by Corwin - Tracker Sup »

Hi Heiko,
In the new build there is no need to display the bookmarks pane for reading bookmarks, and viewer component does not need to be in the visible area. Also please note that page numbers are displayed by JS which is zero based, so to see the real page number you should add 1.

Code: Select all

s += '=====' + (this.pageNum + 1);
If you have any PDFs in which you cannot get the right bookmark page number please send it to us, so we can investigate the problem here.

HTH.
HeikoH22
User
Posts: 6
Joined: Tue Jul 14, 2009 10:06 am

Re: Error with pageNum

Post by HeikoH22 »

Hello,

Once page numbers are read in correctly and another time not, even within one document.

Codes are called on as follows:

Code: Select all


Call pdfDateivorschau.OpenDocument("C:\Test.pdf", strPasswort, id, PXCVA_Flags.PXCVA_NoUI)
JavaScript_Code (id)

Sub JavaScript_Code(DokumentenNr)
  
    'Alle Bookmarks werden ausgelesen
    jsCode = "function DumpBookmark(bkm, nLevel)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "var s = '';"
    jsCode = jsCode & "for (var i = 0; i < nLevel; i++) s += ' ';"
    jsCode = jsCode & "s += '+-';"
    jsCode = jsCode & "bkm.execute(this.gotoNamedDest(bkm.name));"
    jsCode = jsCode & "s += bkm.name;"
    jsCode = jsCode & "s += '=====' + (this.pageNum + 1);"
    jsCode = jsCode & "s += '\n';"
    jsCode = jsCode & "if (bkm.children != null)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "for (var i = 0; i < bkm.children.length; i++)"
    jsCode = jsCode & "s += DumpBookmark(bkm.children[i], nLevel + 1);"
    jsCode = jsCode & "}"
    jsCode = jsCode & "return s;"
    jsCode = jsCode & "}"
    jsCode = jsCode & "DumpBookmark(this.bookmarkRoot, 0);"

Call pdfDateivorschau.RunJavaScript(jsCode, jsResult, DokumentenNr)


Further I tried the following:

Code: Select all

Sub JavaScript_Code(DokumentenNr)
    
    'Alle Bookmarks werden ausgelesen
    jsCode = "function DumpBookmark(bkm, nLevel)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "var s = '';"
    jsCode = jsCode & "for (var i = 0; i < nLevel; i++) s += ' ';"
    jsCode = jsCode & "s += '+-';"
    jsCode = jsCode & "bkm.execute();"
    jsCode = jsCode & "s += bkm.name;"
    jsCode = jsCode & "s += '=====' + (this.pageNum + 1);"
    jsCode = jsCode & "s += '\n';"
    jsCode = jsCode & "if (bkm.children != null)"
    jsCode = jsCode & "{"
    jsCode = jsCode & "for (var i = 0; i < bkm.children.length; i++)"
    jsCode = jsCode & "s += DumpBookmark(bkm.children[i], nLevel + 1);"
    jsCode = jsCode & "}"
    jsCode = jsCode & "return s;"
    jsCode = jsCode & "}"
    jsCode = jsCode & "DumpBookmark(this.bookmarkRoot, 0);"

Call pdfDateivorschau.RunJavaScript(jsCode, jsResult, DokumentenNr)

Best regards


Heiko
Corwin - Tracker Sup
User
Posts: 664
Joined: Tue Nov 14, 2006 12:23 pm

Re: Error with pageNum

Post by Corwin - Tracker Sup »

Hi,
Sorry but we cannot reproduce such problem here.

We would be grateful if you could send us sample project and PDF file, so we can reproduce your problem here, pls include a link back to the topic here in your email for reference.

email to : pdfxview AT tracker-software.com

pls remove spaces and insert '@'


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

Re: Error with pageNum

Post by Stefan - PDF-XChange »

Hello Heiko,

Could you please try with the latest builds of our Viewer SDKs as we are not able to reproduce your problem with the example you provided in the mail.

Best Regards,
Stefan