Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2934
  • Last Modified:

Display the name of a PDF bookmark in the header of the bookmarked page

Hi,

I'll make this hypithtical because the actual situation is more complicated.   I have a PDF that has bookmarks referencing different pages in the document.  What I would like to do is have the bookmark's name posted at the top of the bookmarked page.

That's it in a nutshell I use Acrobat Professional so I would like to write a javascript to create the text at the top of each page with a bookmark with the bookmark's name.

The reason is these files are being split apart by bookmark and I would like to display the bookmarks name on the new files first page. its not for formal usage so it doesn't really matter where or how the text with the bookmarks name appears.

Hopefully this is easier than it sounds. Thanks for the tips.


Josh
0
joshcallahan1
Asked:
joshcallahan1
  • 3
  • 3
1 Solution
 
Karl Heinz KremerCommented:
The problem is that a bookmark is not necessarily a link to a page, a bookmark can for example also open a web page. A bookmark is also not a property of the target page - the bookmark tree is independent of the page tree. When you traverse the bookmark tree in JavaScript, you can get the name of a bookmark, but you cannot get it's "action", so you don't know what it does when executed (but, you can execute it).

This means that with just JavaScript, your idea will not work. You could write an Acrobat plug-in to analyze the bookmark actions (or do that with the free iText library), but that would be a lot more complicated than to just add a few lines of JavaScript to your document.

If you want to go the plug-in route, it's beyond the scope of an EE question. I can give you some pointers, but you would have to do a lot of homework to get familiar with the 'guts' of a PDF file first.
0
 
joshcallahan1Author Commented:
Khkremer,

Before I Accept your answer I have one more scenario to ask you about.  These bookmarks I'm referring to are created when a bunch of small PDF files are combined into one large PDF.  

In Acrobat when you combine PDF files into one PDF it automatically creates a bookmark named after each PDF file.  Is there any way to add the name of a PDF file to the first page of the file before the files are combined?  I could just run a batch involving the name of the file before hand and then combine them.

This may need to be opened under another question but I figured you may know. Thanks,


Josh
0
 
Karl Heinz KremerCommented:
Yes, that would work. You would add a form field, and then fill that form field with the filename. How familiar are you with Acrobat's JavaScript?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
joshcallahan1Author Commented:
I'm a VBA man I have not written much javascript, if you could give me a nudge in the right direction I would appreciate it. Thanks,

Josh
0
 
Karl Heinz KremerCommented:
Sorry for the delay.

Create a new batch sequence and select to run a JavaScript as part of the sequence, using the following code. You should be able to adjust the code to meet your needs by changing the location and size of the field. You can find more information about the Acrobat JavaScript implementation here:
http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?href=JavaScript_SectionPage.70.1.html&accessible=true


var inch = 72;

// Position a rectangle 
var aRect = this.getPageBox( {nPage: 0} );
aRect[0] += .5*inch;            // from upper left hand corner of page.
aRect[2] = aRect[0]+2*inch;    // Make it 2 inch wide
aRect[1] -= .5*inch;
aRect[3] = aRect[1] - 24;       // and 24 points high
	
// Now construct a button field with a right arrow from ZapfDingbats
var f = this.addField("FileName", "text", 0, aRect )
f.value = this.documentFileName;

Open in new window

0
 
joshcallahan1Author Commented:
Code worded great!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now