Creating PDF Bookmarks from a Text File
AutoBookmark plug-in for Adobe® Acrobat®
- Introduction
- The AutoBookmark™ plug-in for Adobe® Acrobat® provides a way to create PDF bookmarks from a plain text control file.
- The control file 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.
- Use any plain text editor or Microsoft Excel application to create a control file from scratch. It is also possible to export existing bookmarks from a PDF document and use it as a template.
- 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® (Standard or Professional) 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… menu.
- Step 2 - Open the "Create Bookmarks From Text File" Dialog
- Select Plugins > Bookmarks > Create From Text File… to open the Create Bookmarks From Text File dialog. The location of the Plugins menu is different in the "New" (post 2022) and "Classic" Adobe Acrobat interface. Please see the link below for details.
- [⚡ How to locate Plugins menu ⚡].
- 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 used in the tutorial:
- Step 4 - Select Data Field Delimiter
- 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 - Select Where to Insert Bookmarks
- Select where to insert bookmarks into existing PDF document. The document may already have bookmarks.
- The following options are available:
- After existing bookmarks
- Before existing bookmarks
- Replace existing bookmarks with bookmarks from the text file
- After an "anchor" bookmark with a specific title
- Before an "anchor" bookmark with a specific title
- Below an "anchor" bookmark with a specific title
- Replace an "anchor" bookmark with a specific title with bookmarks from the text file
- "Anchor" bookmark for inserting bookmarks is determined by a text search. It is possible to use a plain text search or use regular expression syntax for advanced text pattern matching. Only top-level bookmarks can be used as "anchors". If there are not any top-level bookmarks with titles matching an anchor bookmark title, then bookmarks are appended after the existing bookmarks. If there are multiple bookmarks matching an "anchor" bookmark title, only the first one is used to insert the bookmarks.
- Here is an example of inserting bookmark after an "anchor" bookmark:
- Click "OK" to generate bookmarks from the selected control file.
- Step 6 - Run Bookmarking
- Press OK button to import bookmarks from the text file and add them to the currently open PDF document.
- The dialog showing the number of bookmarks created will be displayed at the end of the processing.
- Step 7 - Examine the Results
- The software creates PDF bookmarks based on the instructions from the control text file. We have only showed a basic control file with the most basic features (bookmark title and a destination page). There are many different options and keywords available for customizing bookmark actions and appearance.
- How To Prepare a Bookmark Control File
- There are multiple different ways that can be used to create a control file. It can be created from the existing bookmarks or it can be created using a a plain text editor (such as Notepad) or using Microsoft Excel. Power users may even generate control files using a script or another custom application.
- Export Existing PDF Bookmarks
- The AutoBookmark™ can export PDF bookmarks into 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.
- This file can be used for importing into another document or serve as a template for creating a custom bookmark control text file.
- Step 1 - Open a PDF File
- Use File > Open… open a PDF file that contains bookmarks that need to be exported.
- Step 2 - Open the "Export Options" Dialog
- Select Plugins > Bookmarks > Export > To Text… to open the Export Options dialog.
- Click "OK" to proceed with export. 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. Use this file as a control file template if necessary.
- Using Keywords
- Optional keywords can be used to specify bookmark actions and appearance.
- Bookmark Actions
- 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:
-
Keyword Description uri Open a non-HTTP web or file link. 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. http:// 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. file:// 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". jscript: 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. plabel: Use plabel: to specify a page label of the destination page. For example, plabel:ix specifies that destination page should have ix label in the PDF file. Page labels are aliases that can be assigned to PDF pages in Thumbs view in Adobe Acrobat. Page labels are resolved to plain page numbers before the bookmark is added to the PDF document. It is not possible to use page labels directly in the PDF link and bookmark actions. menu: Use menu: to execute menu item. For example, menu:FirstPage keyword sets bookmark's action to display a first page of a document. Standard named actions include: NextPage, PrevPage, FirstPage, and LastPage. NewWindowYes Use NewWindowYes to open a linked document in the new window. NewWindowNo Use NewWindowNo to open a new document in the same window. InheritZoom Use InheritZoom keyword to set bookmark zoom type to "Inherit Zoom". FitWidth Use FitWidth keyword to set bookmark zoom type to "Fit Width". FitVisible Use FitVisible keyword to set bookmark zoom type to "Fit Visible". FitPage Use FitPage keyword to set bookmark zoom type to "Fit Page". ActualSize Use ActualSize keyword to set bookmark zoom type to "Actual Size". - Bookmark Appearance
- Use the following keywords to specify appearance of the individual bookmarks:
-
Keyword Description bold Use bold keyword to set bookmark title appears in bold text. italic Use italic keyword to set bookmark title appears in italic text. red Use red keyword to set bookmark title appears in red color. blue Use blue keyword to set bookmark title appears in blue color. green Use green keyword to set bookmark title appears in green color. #xxxxxx 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). - Sample Control File
- Here is a sample control file (comma-delimited) that uses most of the appearance keywords. Keywords are shown in blue, destination pages in red and bookmark titles appears in green color.
-
@@ This is a comment line -----------------------------
Chapter One, open, bold,
Paragraph A, 1 , close, bold,italic, ActualSize
Page one, 1, italic, blue
Page two, 2, italic, blue
Page three, 3, italic, blue
Paragraph B, 4 , close, bold,italic, InheritZoom
Page 4, 4, italic, red
Page 5, 5, italic, red
Page 6, 6, italic, red
@@ This is a comment line -----------------------------
Chapter Two, open, bold
Paragraph C, 1 , close, bold, FitWidth
Page 7, 7, italic, #FF7F50
Page 8, 8, italic, #FF7F50
Page 9, 9, italic, #FF7F50
Paragraph D, 4 , close, bold, FitVisible
Page 10, 10, italic, #FF00FF
Page 11, 11, italic, #FF00FF
Page 12, 12, italic, #FF00FF
Appendix A, 13, FitPage
Appendix B, 14, FitPage
Index, 15 - Here is styling created when using the above control file:
- Another set of examples illustrates advanced features such as linking to web pages, starting external applications, executing menu items, using named destinations, and opening documents:
-
View AutoBookmark Webpage, http://www.evermap.com/autobookmark.asp
Start External Application, file://myapplication.exe
Open Microsoft Word File, file://mydocument.doc
Open Another PDF Document, file://anotherpdf.pdf
Open Document In New Window, file://anotherpdf.pdf,NewWindowYes
Open Document In Same Window, file://anotherpdf.pdf,NewWindowNo
Go to a page in another PDF, 1,file://anotherpdf.pdf
Go to a named destination, @FirstChapter
Go to a named destination in another document, @FirstChapter,file://anotherpdf.pdf
Execute a menu item (Go to Next Page), menu:NextPage