Creating PDF Bookmarks from a Text File Using The AutoBookmark™ Plug-in For The Adobe® Acrobat®
Introduction
The AutoBookmark plug-in provides a method for creating PDF bookmarks from a plain text control file that contains bookmark definitions in the easy to use format. This method can be used to generate multi-level bookmarks with the following actions:
  • Go to a page in current document
  • Go to a page in another document
  • Open a web link
  • Open a file
  • Run a JavaScript Code
  • Execute menu item
The control file format uses a delimited text file format (comma, tab, semicolon).  It contains bookmark titles and optional attributes such as text style, color, zoom, destination page, open/close state, named destination and optional keywords for specifying bookmark actions. The following actions are supported:
This operation is also available in the Action Wizard (Acrobat's batch processing tool) and can be used for automating of document processing workflows.
Prerequisites
You need a copy of the Adobe® Acrobat® along with the AutoBookmark™ plug-in installed on your computer in order to use this tutorial. You can download trial versions of both the Adobe® Acrobat® and the AutoBookmark™ plug-in.
How To Create PDF Bookmarks From Text File
Step 1 - Open a PDF File
Start the Adobe® Acrobat® application and open a PDF file using “File > Open…”.
Step 2 - Open the "Create Bookmarks From Text File" Dialog
Select "Plug-Ins > Bookmarks > Create From Text File…" to open the "Create Bookmarks From Text File" dialog.
Step 3 - Select a Control File
Press the "Browse..." button and select a bookmark control file. Click here to learn how to prepare a bookmark control file.
 Here is an example of the control text file that is used in the tutorial:
Step 4 - Select a Control File
Input control file will be loaded into a preview area. Select field delimiter to use while parsing this file (comma, tab, semicolon and space characters can be used as a delimiter). Optionally, select "Default Zoom" and "Default Color" options. These options will be used for bookmarks that do not have corresponding attributes specified. Click "OK" to generate bookmarks from the selected control file.
Step 5 - Check the Bookmarking Stats
The dialog showing bookmarking results will be displayed at the end of the processing. Click "OK" to finish.
Step 6 - Examine the Results
The sofware creates PDF bookmarks based on the instructions from the control text file:
How To Prepare a Bookmark Control File
There are multiple different way that can be used to create a control file. It can be automatically created from existing bookmarks or it can be created from scratch in a text editor or a spreadsheet. Power users may even generate control files from a script or code.
Option 1 - Export Bookmarks Into a Control File
The AutoBookmark™ plug-in for the Adobe® Acrobat® can export PDF bookmarks to a plain text file format with most bookmark attributes: title, destination page number, indentation, style, color, associated action type, destination view, zoom factor and external file references. Titles are properly indented to reflect parent-child relationships between bookmarks.
Step 1 - Open a PDF File
Start the Adobe® Acrobat® application and using “File > Open…” open a PDF file that contains bookmarks that need to be exported.
Step 2 - Open the "Export Options" Dialog
Select "Plug-Ins > Bookmarks > Export > To Text…" to open the "Export Options" dialog.
Step 3 - Specify Export Options
Select “Export all bookmarks” to export all existing bookmarks from the current PDF document. Specify other export options as required.
Optionally, select “Export only bookmark branches with hyperlinks” and select a subset to specify what kind of bookmark need to be exported: all bookmarks with hyperlinks, only bookmarks pointing to a page, to a document, that open a web link, or bookmarks that run a JavaScript code.
Click "OK" to proceed.
Step 4 - Examine the Results
The sofware creates a control file in a plain text format and opens it in a default text editor (typically, it is a Notepad). Examine/edit the file if necessary, close it once done.
Option 2 - Create a New Control File
Use any text editor of your choice (the Notepad for example) to create a bookmark control file.
Step 1 - Create a New Text File
Create a new blank document (in the Notepad for example).
Step 2 - Add Bookmark Definitions
Add bookmark definitions. Each bookmark definition record should occupy only a single line and is required to contain at least one element – a bookmark title. All other bookmark attributes are optional and can be added after a bookmark title using a comma or a tab as a field delimiter.
Left indentation is used to determine parent-child relationships. It is recommended to use "Tab" or space symbols for indenting text lines (do not use tab or space delimiter at the same time). Note that bookmark destination page should always follow the title (if a page number is specified). It cannot appear in any other position in the record. All other attributes can appear in any order. Blank lines are allowed in the file and will be ignored. The example below shows the bookmark structure and destination pages (pages 5, 10, 15 and 20) associated with four of the child bookmarks.
Note, that if a valid page number is specified, then a “Go to a page in this document” action is assigned to a bookmark. If a page number and a file definitions appear in a same record, then a "Go to a page in another document" action is assigned to the bookmark.
Use the following keywords after a bookmark title to optionally define bookmark action attributes:
  • Use "uri:" or "http://" to open a web link. For example, type "uri:http://www.cnn.com", then this internet location will be displayed in the browser when user clicks on the bookmark.
  • Use "uri:" keyword while specifying non-HTTP links such as links to files. Examples: "uri:myfile.pdf" - refers to file myfile.pdf located in the same folder as a current document, or "uri:myfile.pdf#myview" - refers to a named destination "myview" located in the file myfile.pdf.
  • Use "file://" to open a file. This keyword specifies a relative path to a file. This keyword can be used to specify two different types of bookmark actions: "Open a file" and "Go to a page in another document".
  • Use "jscript:" to run a JavaScript code when user clicks on the bookmark.
  • Use "@destination" to specify a named destination to use. For example, "@FirstParagraph" entry will refer to a named destination "FirstParagraph". Named destinations can be used for both local and remote page references.
  • Use "plabel:" to specify a page label of the destination page. For example, "plabel:ix" specified that destination page should have ix label in the thumbnail view.
  • Use "menu:" to execute menu item. For example, "menu:FirstPage" keyword sets bookmarks action to display a first page of a document. Standard named actions include: "NextPage", "PrevPage", "FirstPage", and "LastPage".
  • Use "NewWindowYes" to open a new document in the new window.
  • Use "NewWindowNo" to open a new document in the same window.
The example below shows results of creating bookmarks from the control text file that contains most of the keywords:
Use the following keywords to define bookmark appearance:
  • Use "bold" to set bookmark title appears in bold text.
  • Use "italic" to set bookmark title appears in italic text style.
  • Use "InheritZoom" to set zoom type to "Inherit Zoom" for the bookmark.
  • Use "FitWidth" to set zoom type to "Fit Width" for the bookmark.
  • Use "FitVisible" to set zoom type to "Fit Visible" for the bookmark.
  • Use "FitPage" to set zoom type to "Fit Page" for the bookmark.
  • Use "ActualSize" to set zoom type to "Actual Size" for the bookmark.
  • Use "red" to set bookmark title appears in red color.
  • Use "green" to set bookmark title appears in green color.
  • Use "blue" to set bookmark title appears in blue color.
  • Use "#xxxxxx" to set bookmark title appears in the custom color. The 6 digit hexadecimal HTML color code will be used to define a bookmark title color. Hexadecimal color codes are widely used for defining colors in HTML and web pages. You can find a complete list of HTML color codes on numerous web pages on the internet (for example http://html-color-codes.com/ has a good selection of colors).
The example below illustrates use of some of bookmark appearance keywords:
Step 3 - Save the File
Save the control text file.
Step 4 - Use the Control Text File
Once the control text file is prepared it can be used by the AutoBookmark™ plug-in to create PDF bookmarks.