How to Export Acrobat Bookmark Names and Page Numbers to a New Document
Question details
The user wants to recursively extract bookmark names and their corresponding page numbers from a PDF file using Acrobat JavaScript and output them into a new document.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Generating a report or a table of contents by extracting existing PDF bookmark data to a separate file.
- Observed behavior
- Requires a decision on the final output format (e.g., plain text, form field contents, or a separate static PDF) before executing the JavaScript extraction.
Determine your desired final output format (such as a simple text string in the JavaScript console, a CSV format, or a brand new static PDF document) before writing your extraction script.
Extract Bookmarks Using Acrobat JavaScript Console
Use a custom JavaScript in the Adobe Acrobat Debugger Console to traverse the bookmark tree and print the names and page numbers.
Acrobat JavaScript provides the ability to recursively inspect the bookmark tree using the bookmarkRoot object.
Because retrieving exact page numbers natively via bookmark properties can be complex, scripts typically read the destination page and output it as text.
Open your PDF in Adobe Acrobat. Press Ctrl + J (Windows) or Cmd + J (Mac) to open the JavaScript Debugger.
In the Console window, write a recursive JavaScript function that iterates over this.bookmarkRoot.children. Extract the 'name' property of each child.
Within your script, use the bookmark's action to evaluate the destination page. Push the bookmark name and page number into an array as a formatted string.
Use console.println() to print the final array. You can then copy this plain text output and paste it into a new Word document, Excel spreadsheet, or text file.

Export to a New PDF Using the Report Object
Use the Acrobat Report object within your JavaScript to automatically generate a brand new PDF document containing the extracted bookmarks.
Use a Third-Party Plug-in for Simple Exporting
Utilize a dedicated Acrobat plug-in to bypass coding and directly export bookmarks to a CSV or text file.
Manage PDF Documents Efficiently with WPS Office
While running complex JavaScript extractions requires Adobe Acrobat, WPS Office offers a free, lightweight, and incredibly intuitive alternative for managing, reading, and editing PDFs. Enjoy a seamless user interface to handle standard PDF tasks without the heavy system requirements.
- 1. Download and Install WPS Office: Visit the official WPS website to download the free suite and follow the quick installation instructions.
- 2. Open Your PDF: Launch WPS PDF and open your document directly within the application.
- 3. Navigate via Bookmarks: Click the Bookmark icon on the left-hand navigation pane to instantly view, rename, or reorganize your document's outline.

Frequently Asked Questions
Can I export PDF bookmarks directly to an Excel file?
Adobe Acrobat does not have a native, one-click button to export bookmarks directly to Excel. You must either use a custom JavaScript to format the output as comma-separated values (CSV) or use a third-party plugin to generate a file that Excel can open.
Why is it difficult to get the exact page number via Acrobat JavaScript?
Bookmarks in PDFs don't always point to a specific page index; they often point to 'Named Destinations' or execute specific actions (like running a menu item). A script must correctly evaluate these destinations to calculate the physical page number, which requires slightly more complex coding.
Is it possible to print just the bookmark list from a PDF?
By default, printing a PDF prints its page content. To print a list of bookmarks, you first need to extract them into a new document (using a JavaScript report or a plugin) and then print that newly generated document.




