PDF In-Depth

Applying a menu bar to all page of a PDF

May 20, 1999

Advertisement
Advertisement
 

The following example shows you just how easy it is to add a menubar to all the pages of a PDF through the use of a PDF template. By using a template you can apply the same field across all pages. Tom's example includes a button that takes the user to the first page of a document as well as a print button.

Download the PDF version with full instructions (76K:PDF).

The menubar is created from a template hidden at the end of the PDF, which gets spawned to every page using JavaScript. The idea came from needing to put a menubar on every page in a document.

The fields are given unique names according to page number. To create your own, first insert a template at the end of a document. Second, use the Tools >> Forms >> Page Templates ... menu item to name the template and turn it off. Third, open the Tools >> Forms >> Document JavaScripts... menu item and add the following JavaScript code:

// Inserts template named "menu" over all pages in document 
// only when template hasn't yet been inserted.  This code can 
// be removed after the template has been spawned.    

// The numFields < 4  is one more than the 
// number of fields in the original document. 
// Doing this keeps the template from 
// spawning more than once. 
if (this.numFields < 4) { 
    	var n = this.numPages; 
    	for (i = 0; i < n; i++){ 
        		this.spawnPageFromTemplate ("menu", i, true); 
    	} 
}   

Taken from Adobe Acrobat Technical Note #5186, Acrobat Forms JavaScript Object Specification.

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Back to the past, 15 years ago! Open Publish 2002

Looking back to 2002, it's amazing how much of the prediction became a reality. Take a read and see what you think!

September 14, 2017
Platinum Sponsor





Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.

Features

Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.