These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Bookmark pageNum

Dan Washington
Registered: Aug 7 2008
Posts: 14

Hello,

I am currently using a folder level Javascript to set the bookmark using this command: this.pageNum = 3;

This works just fine, however when the user adds pages to the document, the page I wanted it to go to is no longer page 3 but the bookmark still goes to page 3.

Is there a way to make this more dynamic so it will be linked to the original page?

Any help would be appreciated.

Thanks,
Dan

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There is a way to use JavaScript to create new bookmarks that use destionations. Just like when you create bookmarks with a menu item. In fact, that is the technique, use JavaScript to call the "NewBookmark" menu item. Unfortunately this is a tricky methodology.

But you are in luck, sort of, next months new JavaScript Corner article is on this exact topic. It'll be posted in a couple of weeks:( It's explains the process and all the gotchas you have to watch out for. And it provides sample code.

For now you should experiment with running this code from the console window.

app.execMenuItem("NewBookmark");

It will create a new bookmark that uses the current view of the page as the destination. So the page view should be setup a head of time. The unfortunate part is that there is no way to control, from JavaScript, where the new bookmark is created. So this has to be a slightly user directed process.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Dan Washington
Registered: Aug 7 2008
Posts: 14
Thomp,

Thanks, I'll look for the article.

I wish this was easier than it is.

Dan
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I wish it was easier as well. Being able to create destinations and apply them with JavaScript would be a big, big help for creating document automation solutions. And would make Acrobat much more useful than it is currently. Unfortunately Adobe seems has a love affair with flashy new functionatily.

It'd be nice to have more of the boring old workhorse functionality like this.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Dan Washington
Registered: Aug 7 2008
Posts: 14
Would creating a named destination be a possible solution?

Is it possible to create a destination in Javascript? I see that I can tell JS to go to a Named Destination ( gotoNamedDest ) ...however I cannot figure out how to create one ( Dynamically)

Would this work?

Dan
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately, named destinations cannot be created with JavaScript:( This of course is part of the problem.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Dan Washington
Registered: Aug 7 2008
Posts: 14
Thom,

I tried the command:

app.execMenuItem("NewDestination");

and it does create a new destination...but can it be renamed, etc...programatically?

I've never wasted so much time trying to figure out something with all of the documentation in front of me.

Thanks for your help, I'll give it a rest for now. and wait for your article.

Thanks,
Dan
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Very clever!! You can't rename the destination, but it does have a name. As long as you keep track of which destination goes to which page you're in good shape. Of course you're kind of guessing at the names. You're good if you start with a clean document.

It's a toss up as to whether using

app.execMenuItem("NewBookmark") or app.execMenuItem("NewDestination")

is better.

BTW: I've wasted tons of time on this kind of stuff. It seems like that's all I ever do. It's the only way to figure out anything about Acrobat. Which is why I created pdfscripting.com. I'm putting all kinds of stuff just like this on it.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

Dan Washington
Registered: Aug 7 2008
Posts: 14
Thanks again. I'll take a look at your website.

Dan
Dan Washington
Registered: Aug 7 2008
Posts: 14
Thom,

Just for Grins...

After you enter the Command

app.execMenuItem("NewDestination");
if you immediately follow it with
app.execMenuItem("Paste");
you can affectively renamed the Destination...

Problem is...SDK indicates the "Paste" menu item is disabled for scripting after acrobat 5.0

Just need to figure out how to "Select" the right text so it will paste what I want into the Destination Name.

Dan
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
There are a couple of things you can do. First, you can use the regular bookmark functions for finding and renaming the newly created bookmark. This is what I've done in the past. If you create the bookmarks one at a time it's possible to find and rename them by just searching for "Untitled".

Second, there is a doc fucntion for selecting text on a page, "doc.selectPageNthWord()". So, you could get the text for pasting this way. I'm doubtful about this methodology, but it's worth a try.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/]http://www.adobe.com/devnet/acrobat/[/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

struggleWithBoo...
Registered: Jul 1 2011
Posts: 3
How to find the article?


gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Search and refine to blogs or tutorials.

PDF Bookmarks: Surveying the options by Duff Johnson
PDF Bookmarks: Surveying the options by Thom Parker
Automating bookmark creation with Acrobat JavaScript by Thom Parker

George Kaiser

struggleWithBoo...
Registered: Jul 1 2011
Posts: 3
Thanks a lot.

All three articles are very helpful.

However, my problem still remains unsolved.

The tool I used is Acrobat JavaScript.

The number of PDF documents needed to add bookmarks is around 800.

The bookmark labels can be extracted by searching with regular expression.

The new bookmarks are added without difficulty but there is no way to set its destination.

So, when are documents are combined into one big PDF document, the bookmarks become
completely useless.

app.execMenuItem("NewBookmark") won't work at all!

It is ignored completely in batch processing.

Any new ideas?

Are there any tools can export and important bookmarks in command line (or batch mode)?

Should I learn Java or VB in order to solve this problem?
If I have to, then which one is the better choice.

Thanks in advance


Mike















struggleWithBoo...
Registered: Jul 1 2011
Posts: 3
Thanks a lot.

All three articles are very helpful.

However, my problem still remains unsolved.

The tool I used is Acrobat JavaScript.

The number of PDF documents needed to add bookmarks is around 800.

The bookmark labels can be extracted by searching with regular expression.

The new bookmarks are added without difficulty but there is no way to set its destination.

So, when all documents are combined into one big PDF document, the bookmarks become
completely useless.

app.execMenuItem("NewBookmark") won't work at all!

It is ignored completely in batch processing.

Any new ideas?

Are there any tools can export and import bookmarks in command line (or batch mode)?

Should I learn Java or VB in order to solve this problem?
If I have to, then which one is the better choice.

Thanks in advance


Mike















Dan Washington
Registered: Aug 7 2008
Posts: 14
Mike,

I found it very difficult to apply a destination dynamically and getting them named properly....I eventually gave up on this...hoping that in some future release of acrobat...they would make this type of "Simple" stuff easier.

I found that creating the bookmarks after my reports are built...(with about 200 separate reports combined)...that the bookmark creating works very well.

I embedded text into the PDF that I search for...then create the bookmark when that string is found. Since I am creating the PDF from scratch, I already know what is in it...so this task is fairly straight forward. These bookmarks do point to a specific page in the document however, and as such...I do not allow manipulation of the document by security settings.

I use Access VBA and Javascript to get this to all happen.

Hope this helps.

Dan