Getting Bookmark Information
In this chapter…
you will learn how to:
- Retrieve a simple list of bookmarks (-bookmark option) — Basic listing of bookmarks in file
- Display the total number of bookmarks (-count option) — Reports the total number of bookmarks
- Create a bookmark list with no level indicators (-nolevel option) — Display a long list of bookmarks
- Show the full path for each bookmark (-path option) — Shows the full path of each bookmark in the file
- Display the page number of each bookmark (-page option) — Reports the page number for each bookmark
- Include named destinations for bookmarks, if they exist (-dest option) — Displays the named destination of bookmarks if they exist
A bookmark is a link to a specific page or view in a document. In Adobe Acrobat and Adobe Reader, a document’s bookmarks are displayed on the Bookmarks tab of the Navigation pane. The figure below shows the Bookmarks tab for the ApUtilsSample.pdf file supplied with APGetInfo.
Retrieving a Simple List of Bookmarks
Use the -bookmark option to list all of the bookmarks in a PDF document, numbered and indented according to level.
Command
$apgetinfo -bookmark inPDFFile
Windows Example
$apgetinfo -bookmark C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -bookmark option on the ApUtilsSample.pdf file. Note that both numbers and indention are used to indicate the bookmark level.
Displaying the Total Number of Bookmarks
To count the number of bookmarks and display the total at the end of the bookmark list, use the -count option with the -bookmarkoption.
Command
$apgetinfo -bookmark -count inPDFFile
Windows Example
$apgetinfo -bookmark -count C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -count /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -count option and the -bookmark option on the ApUtilsSample.pdf file. The total number of bookmarks in the document appears at the bottom of the list.
Creating a Bookmark List with No Level Indicators
To list the bookmarks without any indication of level, use the -nolevel option with the -bookmark option.
Command
$apgetinfo -bookmark -nolevel inPDFFile
Windows Example
$apgetinfo -bookmark -nolevel C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -nolevel /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -nolevel option and the -bookmark option on the ApUtilsSample.pdf file. The bookmark entries do not include level numbers, and they are displayed flush left.
Showing the Full Path for Each Bookmark
To show the full document path for each bookmark, use the -path option with the -bookmark option.
Command
$apgetinfo -bookmark -path inPDFFile
Windows Example
$apgetinfo -bookmark -path C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -path /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -path option and the -bookmark option on the ApUtilsSample.pdf file. For each bookmark entry, the full document path is displayed, beginning with the document title. The entries are not numbered or indented to indicate levels. Levels within each entry are separated by a pipe, or vertical bar (|).
Displaying the Page Number of Each Bookmark
To show the document page number of each bookmark, use the -page option with the -bookmark option.
Command
$apgetinfo -bookmark -page inPDFFile
Windows Example
$apgetinfo -bookmark -page C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -page /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -page option and the -bookmark option on the ApUtilsSample.pdf file. A page number appears to the right of each bookmark entry.
Including Bookmark Destinations
Named destinations are links to specific locations in the current or other documents. They can be user defined or generated automatically by PDF creation software. If any of the bookmarks in a document have named destinations, you can include them in your output by using the -dest option with the -bookmark option and the -page option.
Command
$apgetinfo -bookmark -page -dest inPDFFile
Windows Example
$apgetinfo -bookmark -page -dest C:\Appligent\APGetInfo\InPDFFile.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -page -dest /Appligent/APGetInfo/InPDFFile.pdf
Result
The figure below shows the results of running apgetinfo with the -dest, -page, and -bookmark options on a PDF which has bookmarks with named destinations. Only the bookmarks for the first three chapters are shown.
Getting Multiple Types of Bookmark Information
You can use two or more options in combination to obtain multiple types of bookmark information.
Command
$apgetinfo [bookmark options] inPDFFile
Windows Example
$apgetinfo -bookmark -nolevel -page -count C:\Appligent\APGetInfo\samples\ApUtilsSample.pdf
UNIX/Macintosh Example
$./apgetinfo -bookmark -nolevel -page -count /Appligent/APGetInfo/samples/ApUtilsSample.pdf
Result
The figure below shows the results of running apgetinfo with the -bookmark, -nolevel, -page, and -count options on the ApUtilsSample.pdf file.