bookmarks Reading

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

Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

bookmarks Reading

Post by Dorwol »

Hello,

I need a way to load the PDF-bookmarks to "my own treeview component". I know, I can use the "Tools-SDK" - and yes, this works perfect with PDF-Files.

But I always load the PDF's directly by stream from the database to the XChange-Viewer.

So my question is: How can I grab the bookmarks from the viewed PDF with or without the Tools-SDK but without to saving the viewed PDF additional as a (often very big) file on the hard drive (too slow)?

For example, can I send the viewed PDF-Doc-Handle to the Tools-SDK or save only the Bookmarks from the viewer as file (or string) and load it to the Tools-SDK?
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

Hi,

Lets keep this all on this thread for simplicty and to save duplication :)

https://forum.pdf-xchange.com/ ... 36&t=11901
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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

John - Tracker Supp wrote:Lets keep this all on this thread for simplicty and to save duplication :)
I'm not sure, if this is the right way. Because, this questions is primary a Tools-SDK+Viewer question. In the other thread, the user abc123abc123 speaks about a Viewer-only solution.

But I need the possiblility to EDIT the bookmarks. This works only with "Tools-SDK" by code and not with the viewer. Or do I understand something wrong?
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

Hi,

You can modify the bookmark text having located a specific string using Javascript - so in principle if that is your need, it is all possible in the Viewer Ax.
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
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

e.g. ...

Code: Select all

function Lookup(b, s)
{
  if (b.children != null)
  {
    for (var i = 0; i < b.children.length; i++)
    {
      if (b.children[i].name == s)
        return b.children[i];
      var c = Lookup(b.children[i], s);
      if (c != null)
        return c;
    }
  }
  return null;
}


function ReplaceBookmarkText(document, sOldText, sNewText)
{
  var b = Lookup(document.bookmarkRoot, sOldText);
  if (b != null)
  {
     b.name = sNewText;
  }
}

ReplaceBookmarkText(this, "Foreword", "New Title");
Hope that helps
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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

> Hope that helps
Not realy! :(
John - Tracker Supp wrote:You can modify the bookmark text having located a specific string using Javascript - so in principle if that is your need, it is all possible in the Viewer Ax.
But only in plain Text, or? :?

1.) I need also the ability to show if a Bookmark string ist colored and/or bold or italic...

2.) Also I don't understand, how do I get the bookmarks via Javascript in my Treeview component? I use a viewer on VB6 - this is no Web environment.

Summarized again:

The user opens a PDF file from the database (directly by stream). Now I will show him all bookmarks in a VB TreeView Control.

As soon as he changed a bookmark (text or formatting), I would like to update the PDF with the help of the SDK tools and save again by stream.

I can find no way to do this for VB6-controls using Javascript. :!:

Currently I only know a way with a saved PDF-file on the hard disk. But my PDFs are all inside a database - and opening by stream.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

I appreciate that with VB it may be easier to code your app using the XCPRO40 functionality to do as required - but it is 'possible' to use the ActiveX and JavaScript - it is not relevant that it is not a web application - JavaScript is perfectly usable within a desktop app and the ActiveX Viewer and you can open and save via a stream - but I would concede that with VB - probably it would be easier to stick to XCPRO40 to do as required, I was just trying to suggest a 'one stop' solution,

You will need to use the following functions :

PXCp_GetRootBMItem
PXCp_BMGetItem
PXCp_BMGetItemInfo
PXCp_BMSetItemInfo

and there is ample documentation in the help file and sample code in C++ which you would need to translate to VB - but it should be relatively identifiable to you - further more - there is a complete VB sample showing the functionality required called : PXCPro_Demo

Specifically see the section for manipulating outlines.
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
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: bookmarks Reading

Post by Vasyl - PDF-XChange »

Hi, Dorwol.
I can find no way to do this for VB6-controls using Javascript. :!:
With PDF-XChange Viewer ActiveX you may run java-script code for example:

Code: Select all

...
On Error GoTo CatchError
Dim jsCode As String
Dim jsResult As String
jsCode = "2+2"
Call CoPDFXCview1.RunJavaScript(jsCode, jsResult)
; look to jsResult
CatchError:
...
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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

Again, I have it already coded with VB and it works PERFECT.

And yes, I use PXCp_GetRootBMItem to grab the Bookmarks-root
For example: "res = PXCp_GetRootBMItem(pdf, bmHandle)"

And yes, I use PXCp_BMGetItem, PXCp_BMGetItemInfo and also PXCp_BMSetItemInfo to save my changes!

This is absolutly no problem for me and it works fantastic with a local save PDF.

My problem is that I DON'T HAVE A SAVED PDF on HDD.

So I need another way to Init the Document.

Actualy I must do this:

res = PXCp_Init(pdf, "...", "...")
res = PXCpVB_ReadDocumentW(pdf, filename, 0)
res = PXCp_GetPagesCount(pdf, PagesCount)
res = PXCp_GetRootBMItem(pdf, bmHandle)
...

So the problem-code-row is "PXCpVB_ReadDocumentW(pdf, filename, 0)". Because I don't have any file-path.
I have only a stream object AND ALSO ALREADY OPENED AND VIEWED in the AX-Viewer-control!

So I'm looking for a way to change the PDF in the viewer or load it from stream to the sdk-tools.

Sorry, I think all the misunderstanding is because my bad english! :|
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

No Problem with the English - we are not so good in other Languages :-)

So you have 2 choices - use Javascript and the Viewer Ax and save the resulting 'Stream' directly once modified as required and indicated previously - this will take a good deal more work (on your part I am afraid - we cannot invest the substantial amount of time required to assist) if using VB - but will yeald a more elegant and satisfactory end result for you and your users - or load, modify and save in the XCPRO40 library and save the file to replace the database image and reload the viewer ...

You cannot have the file open in the Viewer and then modify in PDF-Tools and then save the stream using PDF-Tools I am afraid. PDF-Tools does not offer a save by Stream method and also if the file is open in the Viewer and PDF-Tools you will have seperate copies and the original must be replaced before the Viewer can open and display the modifcations.

It is likely that in Version 5 of our libraries and V3 of the Viewer will allow manipulation closer to your core needs as the libraries/Viewer etc are a common set of functions in a layered SDK - but for now the approach you outline is not compatible with the current architecture.

Hope that helps
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
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: bookmarks Reading

Post by Vasyl - PDF-XChange »

I have only a stream object AND ALSO ALREADY OPENED AND VIEWED in the AX-Viewer-control!
So I'm looking for a way to change the PDF in the viewer or load it from stream to the sdk-tools.
Currently our PDF-Tools SDK does not contain the PXCp_ReadDocumentFromStream(pdf, stream, 0) feature...
I can suggest you the other way:
1. Open document in our PDF-Viewer ActiveX Control from stream object for viewing and changing.
2. For exporting bookmarks:
a) create a temporary file
b) call pdfViewerActiveX.SaveDocument(docId, temporaryFileName, PXCVA_DocumentSaveCopyAs, PXCVA_Sync Or PXCVA_NoUI)
c) do read and export bookmarks by:
PXCp_Init(pdf, "...", "...")
PXCp_ReadDocumentW(pdf, temporaryFileName, 0)
...
PXCp_Delete(pdf)
d) delete temporary file.

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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

Vasyl-Tracker Dev Team wrote:
I can suggest you the other way:
1. Open document in our PDF-Viewer ActiveX Control from stream object for viewing and changing.
a) create a temporary file
b) call pdfViewerActiveX.SaveDocument...
c) do read and export bookmarks by ...
d) delete temporary file.
Hey guys, This is exactly the actualy way of how I already proceed it. Is my webcam powered on? :shock: :mrgreen:
But (and this is the sad) it is very very slow. Especially when there are PDF's with very many pages.
Furthermore, it was all the work (to do it all via streaming) for nothing. :cry:
John - Tracker Supp wrote: So you have 2 choices - use Javascript [...] this will take a good deal more work ... we cannot invest the substantial amount of time required to assist (*yes, I do understand this 100%*)
If I try it with Javascript, I have 3 questions more:
1.) Do the user needs some installed extra stuff (like java-engine or other DLL's)
2.) What if the user has disabled JavaScript in the browser. JS works anyway in your Docu-viewer, right?
3.) How can I grab the BM-node-fomating by JS (like BMIM_Color, BMIM_Style, ...?)

BTW: I pray there will come a better way with V3 of viewer or v5 SDK-Tools...!
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: bookmarks Reading

Post by Ivan - Tracker Software »

If I try it with Javascript, I have 3 questions more:
1.) Do the user needs some installed extra stuff (like java-engine or other DLL's)
2.) What if the user has disabled JavaScript in the browser. JS works anyway in your Docu-viewer, right?
3.) How can I grab the BM-node-fomating by JS (like BMIM_Color, BMIM_Style, ...?)
1) no, nothing is required
2) JS in the viewer has nothing in common with JS in the browser
3) when you executing JS code in the AX you catch the result string - what will be in this string depends upon the script you have executed. So, your script can format the string with bookmark item's color and styles and on the VB side you have to parse it; yes, agree, it is not so simple, but it is possible.
BTW: I pray there will come a better way with V3 of viewer or v5 SDK-Tools...!
Yes, in V3/V5 it is much better and easier.
PDF-XChange Co Ltd. (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.
abc123abc123
User
Posts: 35
Joined: Mon Oct 17, 2011 2:36 pm

Re: bookmarks Reading

Post by abc123abc123 »

If I only want to use the Ax I must use JS? I'm right?
The other functions like PXCp_* refer only to the PDF-Tools SDK? I couldn't find anything within the Ax.

The main reason, why I want to use a own bookmark tree is that the actual bookmark pane is not completely touchable (e.g. the close button is too small or the scrollbars are to small). Will this be better customizable in V3 of Ax?
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

abc123abc123 wrote:The other functions like PXCp_* refer only to the PDF-Tools SDK?
Yes! ("PDF-Tools SDK" and also as a part of "PDF-XChange Pro SDK")
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

@Tracker-Team
Please, hope you can help me.

Is there at least a quick way (Boolean-Flag or BM-Count) to check in the AX-viewer (PDF already opened by stream), if it contains bookmarks?

This will help me very much. Because I don't need to save every document as file. With a Flag like this, I need only to save PDF's as a file, if it realy contains bookmarks. :idea: So my application is much more faster! 8)
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: bookmarks Reading

Post by Ivan - Tracker Software »

Is there at least a quick way (Boolean-Flag or BM-Count) to check in the AX-viewer (PDF already opened by stream), if it contains bookmarks?
you can use the following JS code:

Code: Select all

function HasBookmarks(document)
{
  return (document.bookmarkRoot.children != null) && (document.bookmarkRoot.children.length > 0);
}
HasBookmarks(this);
it returns string "true" if there are bookmarks, and "false" otherwise.

P.S. But, please note, we cannot write code for you every time.
PDF-XChange Co Ltd. (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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

Ivan - Tracker Software wrote:
P.S. But, please note, we cannot write code for you every time.
Thank you! But I did not know that this code had to be written. :oops:
I thought for this is already a property/flag available.
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

Hi Dorwol,

no problem - its done now - but obviosuly there are limits to the support time we can expend on any one topic and with any one client - and I think its time for you to dig into the 'vast landscape' that is Javascript and investigate what possibilities exist.

We are always ready and willing to help - but you will certainly get a quicker and more enthusiastic reponse when you have tried to code yourself - and just need a little assistance to debug or correct if all attempts by you have failed :)

Human nature dictates that we all like to see someone try to do something themselves ... and then ask for help :)

Have a great day !
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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

OK, now I need is one last step and I'm complete done!!!
Finally I want by clicking of any treeview-node to jump to the bookmark of the ax-viewer PDF.

But this will code not work:

vArr(0) = 36010
vArr(1) = "MyBookmarkName"
vDataIn = vArr
vwAXViewer.DoVerb "", "ExecuteCommand", vDataIn, Nothing, 0

What do I do wrong again? :cry:
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: bookmarks Reading

Post by Ivan - Tracker Software »

Finally I want by clicking of any treeview-node to jump to the bookmark of the ax-viewer PDF.
you want to select particular bookmark in viewer's bookmark's view, or execute actions linked to this bookmark (usually it is 'GoTo' action)?
PDF-XChange Co Ltd. (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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

I want to jump to the bookmark position in the PDF Document.

So the user can click in my TreeView component on any already listet Bookmark and in the AXViewer the PDF will show this page. Do you understand?

:!: The Build-In Bookmark-treeview from your AXViewer is always complete hidden.

Remark: You need not must help me, if you must write JavaScript code for me. I to fully respect your statement from Jan 10, 2012 5:14 pm and accept that this is not work for you is reasonable.
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3586
Joined: Thu Jul 08, 2004 10:36 pm

Re: bookmarks Reading

Post by Ivan - Tracker Software »

To launch the action(s) associated with the bookmark item, you have to find object for this particular bookmark, and call its execute() function.
Most important question is how to find bookmark object corresponding for the item into your tree list
PDF-XChange Co Ltd. (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.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

Unfortunately, I do not understand your question.
Do I understand it correctly, that this does not possible with the Axviewer?
User avatar
John - Tracker Supp
Site Admin
Posts: 5223
Joined: Tue Jun 29, 2004 10:34 am

Re: bookmarks Reading

Post by John - Tracker Supp »

I think perhaps it is also that we dont fully understand what you want....

Are you trying to display the bookmark tree in our viewer automatically to your clients ?
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
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

John - Tracker Supp wrote:Are you trying to display the bookmark tree in our viewer automatically to your clients ?
No, only my own Bookmark-tree next on the right side of your viewer:

1.) The user see the PDF on the left and a bookmark menu on the right.
2.) Now, the user clicks on a node in the bookmark treeview.

But if you say, this is not possible, It's OK for me. And also please don't write code for me.
My question ist only, if there is a command in your viewer to go to this bookmarked page, please let me know.
Last edited by Dorwol on Sat Jan 14, 2012 9:23 am, edited 1 time in total.
Dorwol
User
Posts: 275
Joined: Mon Aug 04, 2008 5:04 pm

Re: bookmarks Reading

Post by Dorwol »

He heee, I've already found a way with JavaScript! :)
Yes, I dig into the 'vast landscape'! :wink:

But if you think there is a better way without JS, let me know.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19883
Joined: Mon Jan 12, 2009 8:07 am

Re: bookmarks Reading

Post by Stefan - PDF-XChange »

Hi Dorwol,

I believe JS is the way to go :)

And great to hear that you managed to make it work yourself!

Cheers,
Stefan
User avatar
Vasyl - PDF-XChange
Site Admin
Posts: 2445
Joined: Thu Jun 30, 2005 4:11 pm

Re: bookmarks Reading

Post by Vasyl - PDF-XChange »

But if you think there is a better way without JS, let me know.
- Sorry but no way to do it without JS, in current version.. Please wait for new version V3...
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: bookmarks Reading

Post by abc123abc123 »

Dorwol wrote:He heee, I've already found a way with JavaScript! :)
Yes, I dig into the 'vast landscape'! :wink:

But if you think there is a better way without JS, let me know.
can you participate us with your solution?
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19883
Joined: Mon Jan 12, 2009 8:07 am

Re: bookmarks Reading

Post by Stefan - PDF-XChange »

Hello abc123,

There is a whole chapter in the JS for Acrobat API reference with all the methods and properties of the bookmark object, and it should be pretty straight forward to write your own code that meets your needs.

In any case - I hope that Dorwol will share what he has come up with :)

Best,
Stefan