Copy link to clipboard
Copied
I thought I'd cracked it with this: bookmarkRoot.createChild({cName: this.documentFileName, cExpr: "this.pageNum++", nIndex: 0});
However, it inserts the bookmark at page 2. I've done some reading and found out why this happens - createChild makes a bookmark on the page after the hidden root bookmark.
Is it possible to achieve?
NB: after running this script on a large number of PDFs my plan is to combine them into one document, then use another script to create a contents list.
Copy link to clipboard
Copied
Bookmarks are part of the document, not pages.
Copy link to clipboard
Copied
I see. We used PDF workflow software that does exactly what I need - it combines PDFs, and creates a new set of bookmarks, named after each section, that point to the correct page view.
Unfortunately that software is very old and has been replaced, and the new software doesn't have this functionality.
I was hoping to get around it with a script but it sounds like it's not possible.
Copy link to clipboard
Copied
What are you trying to achieve with your bookmark? The code you posted creates a bookmark with an action that jumps to the next page. Is that what you want? Is that maybe the reason you think that it's adding the bookmark to the second page because when you are on the first page of your document and you click on it, it jumps to page two?
If you want the bookmark to always go to the first page, try this instead:
bookmarkRoot.createChild({cName: this.documentFileName, cExpr: "this.pageNum=0;", nIndex: 0});
Copy link to clipboard
Copied
That solves one problem, thank you for pointing out the error. Clicking the bookmark now takes me to the first page as intended. Unfortunately when my new workflow combines the PDFs, every bookmark then points to the first page of the combined document.
Copy link to clipboard
Copied
When you add a document at the end of a document with 5 pages you must use this.pageNum=5;
Copy link to clipboard
Copied
So what I need to do is:
Add document A
Add bookmark
If number of pages is odd, add blank
Calculate total pages
Add document B
Add bookmark (total pages +1)
If number of pages is odd, add blank
Calculate new total pages
etc...
Sounds like this is waaaay beyond me! I'll get on to the people who provide our workflow software and see if they can help us out.
Thanks for the help!
Copy link to clipboard
Copied
this.numPages will you give the number of pages in the open document.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now