Read the bookmarks

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

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

heiko22
User
Posts: 16
Joined: Thu Sep 27, 2007 10:24 am

Read the bookmarks

Post by heiko22 »

Hello,

I use the PDF-Viewer ActiveX-Components in my VB6 Project.

I don't know how to read out the bookmarks and the page number from the pdf-files.
I have try to read the bookmarks with JavaScript but always the return value is empty.

Could you be so kind and provide an example code for Visual Basic?


best regards


Heiko
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Post by Ivan - Tracker Software »

To get number of pages via JavaScript, you need to run the script

Code: Select all

this.numPages
To get bookmarks tree:

Code: Select all

function DumpBookmark(bkm, nLevel)
{
    var s = "";
    for (var i = 0; i < nLevel; i++) s += " ";
    s += "+-";
    s += bkm.name;
    s += "\n";
    if (bkm.children != null)
    {
        for (var i = 0; i < bkm.children.length; i++)
           s += DumpBookmark(bkm.children[i], nLevel + 1);
    }
    return s;
}
DumpBookmark(this.bookmarkRoot, 0);
By the way, the returned bookmarks tree will be returned as a string which I'm afraid isn't acceptable.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
heiko22
User
Posts: 16
Joined: Thu Sep 27, 2007 10:24 am

Read the bookmarks

Post by heiko22 »

Thank you very much for the help and your excellent support.


Best regards


Heiko
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom

Post by John - Tracker Supp »

:)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
heiko22
User
Posts: 16
Joined: Thu Sep 27, 2007 10:24 am

Read the bookmarks

Post by heiko22 »

I am sorry, I still have problems to read out the bookmarks of some
of the pdf-files. I include one of those that cause problems.

It is easy to open the pdf-file. However, if I want to read out the
bookmarks, I get the error code No. 438 and closing te file I get an
interruption message from PDFXCview.exe Accordingly I can finish Visual Basic only with the help of the task manager.

From other pdf-programs the file is shown with all bookmarks.

In the following I include the code I use to read out the bookmarks:

Code: Select all

Sub JavaScript_Code(DokumentenNr)
    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 & "s += bkm.name;"
    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 frmVerzeichnis.PDFDateivorschau.RunJavaScript(jsCode, jsResult, DokumentenNr)

end sub

Code: Select all

    Call frmVerzeichnis.PDFDateivorschau.OpenDocument(Pfad, "", id)

   JavaScript_Code (id)

What may be the reason?

Best regards


Heiko
You do not have the required permissions to view the files attached to this post.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Post by Ivan - Tracker Software »

There was tre problem with reading bookmarks when the bookmark tree was large. Now the problem is fixed and the fix will be available later today with new build.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
heiko22
User
Posts: 16
Joined: Thu Sep 27, 2007 10:24 am

Read the bookmarks

Post by heiko22 »

Hello,

I have a last question.

I mentioned the reading out of page numbers. I was talking about the page numbers of each bookmark for the navigation. By "this.numPages", as recommended, I get the page numbers of the entire file. I will give an example.

Code: Select all

    'Alle Bookmarks einer PDF-Datei 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 & "s += bkm.name + '; ' + 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);"


    Call frmVerzeichnis.PDFDateivorschau.RunJavaScript(jsCode, jsResult, DokumentenNr)
In the help-file I did not get hints.

Best regards


Heiko
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Post by Ivan - Tracker Software »

Into JavaScript's object model for PDF, object bookmark doesn't have property pageNum. It is because bookmark not always moves to the specific page (but as usually), it can make any other allowed action (like running JavaScript action, opening URL, etc.).
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
heiko22
User
Posts: 16
Joined: Thu Sep 27, 2007 10:24 am

Post by heiko22 »

Hello

I am still trying to integrate an own navigation in my program. I am only missing the path that helps to obtain the pagenumber of each bookmark. I nearly give up.

However, I just found "indexes" in the JavaScript-object ", by which one obtains an array with all index-objects

Code: Select all

for (var i = 0; i < search.indexes.length; i++) {
console.println("Index[" + i + "]=", search.indexes[i].name);
}
I tried to integrate the code into a function and to incorporate it in my project. However, with no success.

Would this search-object be the right path, to set up an own navigation? Would I be able to jump directly to the different bookmrks in the pdf-file?

Hopefully I can create an own navigation by the component PDF XChange Viewer. Is that correct?

Many thanks
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Post by Ivan - Tracker Software »

The search object doesn't realized for now into the PDF-XChange viewer.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
allanjn
User
Posts: 5
Joined: Wed Oct 03, 2007 5:15 am

bookmarks for navigation

Post by allanjn »

I've been reading quite a bit about this. Ideally, we could create named destinations in the document, and then link the bookmark to the destinations via the 'action' on a bookmark.

However, there is no way to create named destinations via javascript.

You _can_ execute javascript that will go to the appropriate page (this.pagenum=x), set the zoom level (this.zoom=xxx), and then scroll to the appropriate place on the page (this.scroll(x,y)).

That works, but what I'd really like to do is create a bookmark from the current view in the viewer. but there is no way that I can find to figure out what the scroll values are for the current view, because 'scroll' is a method, not a property of the document (or viewer).

Can someone suggest a way of creating a bookmark action (or destination) from the current viewport of the viewer?

Ideally we would have a 'destinations' api which could be manipulated, but this still doesn't solve the question of how to determine what the current viewport values (scroll values) are.

Are you aware of any plans to provide features that would allow this type of thing? Seems to me that you could expose some of the properties of the 'pan and zoom' pane, as that would have all the appropriate values. :)

Thanks!

P.S. - I know that the javascript restrictions are not your problem - they're part of the adobe specification. Overall I've been very impressed with the viewer SDK features. Great product!
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3556
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada

Post by Ivan - Tracker Software »

There is document's property viewState, but for now it is not supported into the PDF-XChange viewer. Will add support of this property into the next build.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
allanjn
User
Posts: 5
Joined: Wed Oct 03, 2007 5:15 am

new build

Post by allanjn »

That is awesome news, and great support! I noticed that the viewState property wasn't working. That should work great. I wonder if I'll be able to save the viewState value as a string in the bookmark and just reset it's value (thereby resetting the view), or whether I'll have to extract the page, scroll, and zoom values from the viewState in order to execute those actions in the bookmark? either way would work - we'll see.

Couple quick questions: When do you expect the next build to be available to the public? How would I be notified I can get this? Where would I download it from?

Thanks!
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom

Post by John - Tracker Supp »

Hi Allan,

the next build should be avilable late this week and we will send out a reminder to all registered licensed users via this option :

https://www.pdf-xchange.com/login/register

otherwise we will post here and obviously update the web site accordingly.
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com
allanjn
User
Posts: 5
Joined: Wed Oct 03, 2007 5:15 am

register

Post by allanjn »

Thanks! as I'm planning on doing as much development as possible before purchasing the license (as recommended :) ), I'm not able to register to receive that update. I'll look forward to your notice in the forum. :)
User avatar
John - Tracker Supp
Site Admin
Posts: 5219
Joined: Tue Jun 29, 2004 10:34 am
Location: United Kingdom

Post by John - Tracker Supp »

Excellent - thanks Allan :)
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com