Tutorials, tools, scripts and samples for scripting Acrobat and PDFpdfscripting.com
HomeVideo TutorialsCopy-n-Paste ScriptsDownload LibraryFree ContentSearchMEMBERS LOG-IN


About Us
Contact Us
Privacy Policy
Refund Policy
Site Video Tour
Terms of Use
Testimonials
Articles
Video Tutorials
Automating Acrobat
Copy-n-Paste Scripts
Download Library
Free Content
Free Videos

Let me know when new content is available.

Home | DocNavigation
 

Scripts for Navigating to a specific document location

Document Navigation:

Document navigation is the process of finding your way through content in a document. Documents are rarely read from start to finish. Unless the document is a novel, users will want to skip around to find the particular content they are interested in. This is especially true for interactive electronic documents, which are used more for providing information than telling stories. Fortunately, Acrobat provides a variety of ways to implement PDF navigation features.

The most obvious navigation features in Acrobat do not require any JavaScript. There is a navigation toolbar with next and previous page buttons, and there is also a sophisticated search feature. On the document itself, there is a hierarchical bookmark listing for jumping to various locations in the PDF. Most PDF conversion tools will automatically create the bookmarks, but it's up to the document developer to make corrections and additions.

JavaScript comes into play, as it does in most other situations, when we want to do something different from the standard built-in functionality. For example, presentations that are intended to be viewed in fullscreen cannot take advantage of toolbar buttons or bookmarks. These types of documents require On-Page navigation controls such as next and previous page buttons, or a popup menu that acts like a table of contents. These types of controls are typically grouped into a button bar along the edge of every page in the PDF. since it's on every page it creates the illusion of an immovable control panel (see figure below). It's also a best UI practice to provide more than one way to do the same thing. So we might also want to provide alternate navigation for documents that are not displayed in full screen.


Navigation Bars are common features on many types of documents


Another place JavaScript can help out is with automating tasks surrounding the navigation feature creation process. For example, adding navigation buttons and links to pages on the PDF and creating bookmarks. Manually adding navigation features can be very time consuming. So, if you consistently add the same navigation features to your documents, it is well worth the effort to automate as much of the process as possible.

Navigation With JavaScript

There are several different ways to navigate a document with JavaScript
  1. Directly modify the page view parameters, page number, zoom level, and scroll postion
  2. Execute menu items for changing the page view
  3. Use Named Destinations
  4. Modify the viewState property
  5. Execute bookmarks as a way of doing indirect navigation
  6. Force the keyboard focus to a form field
  7. Force a word search
  8. Use the Document Open parameters when opening a document from an URL
Some of these methods definitely allow for navigation fucntionality outside of Acrobat's UI, so they are obviously worthwhile to implement in JavaScript. But some of these methods are identical to methods available in Acrobat's UI, such as executing an Acrobat Menu Item and doing a word search. For example, a next page button can be easly added to a PDF page by placing a button on the page, selecting the actions tab on the properties dialog, and then adding a Mouse Up "Execute a Menu Item" action that runs the "Next Page" menu item. So why would we choose to do this in JavaScript? The answer is so that the process of adding the button to all pages in the PDF can be automated.

JavaScript can be used to add buttons on all the pages of a PDF, but it can only add JavaScript actions to those buttons. So instead of the button performing an "Execute a Menu Item" action, it performs a "Run a JavaScript" action that accomplishes the same thing. When an automation script is used to create navigation elements, the actions those elements perform must be implemented with JavaScript.

Scripts:

All of the scripts listed below are for either using a specific type of navigation feature, or for automating the addition of navigation features to a PDF. Typically, a navigation script is attached to a button or link on a PDF page. However, these scripts can be used literally in any scripting context where a PDF is being displayed, from a bookmark script, a page action script, or even an automation script.

Using the Search Object
The Acrobat JavaScript Search Object is a scripting interface to Acrobat's search mechanism. It can be used for everything from simple searches on the current document to elaborate multilevel searches involving several documents. . . . keep reading
Indirect Document Navigation Using Bookmarks
WindJack Solutions, Inc.
Bookmarks can be used to make adding advanced document navigation features a much easier task for the document designer, for example by allowing the document creator to design popup menus purely by manipulating the bookmarks. . . . keep reading
Document Navigation using View States
WindJack Solutions, Inc.
The viewState Object was added to Acrobat 7.05 and encapsulates all of the standard document navigation parameters as well as some view parameters not previously included in the Acrobat JavaScript model. . . . keep reading
Using Named Destinations
WindJack Solutions, Inc.
Named Destinations are not only an easy way to navigate within a document, they can also be used for navigating to locations in external documents. . . . keep reading
Simple Document Navigation
WindJack Solutions, Inc.
Basic and easy to implement document navigation scripts. These scripts use the legacy navigation parameters (page number, zoom, and scroll), existing Acrobat menu items, and an URL query string to perform both document navigation tasks. . . . keep reading