How to Split PDFs by Bookmarks with Numbered Filenames
Question details
The user wants to split a large PDF document using its top-level bookmarks while ensuring the resulting files are sorted sequentially in Windows Explorer.

- Product
- PDF Editor
- Device & OS
- Windows
- Scenario
- Splitting a large PDF document into smaller, individual files based on existing bookmarks without losing chronological order.
- Observed behavior
- By default, splitting by bookmark names results in alphabetically sorted files in Windows, which ruins the original reading sequence unless numbered prefixes are added.
Ensure your PDF document already has the necessary top-level bookmarks properly set up. It is highly recommended to back up your original PDF file before running any batch renaming scripts or split actions.
Rename Bookmarks with Numbered Prefixes Before Splitting
Add a zero-padded number sequence to each bookmark name (e.g., 01_BookmarkName) so that extracted files maintain their proper chronological order in Windows Explorer.
Windows Explorer sorts files alphabetically by default. If you split a PDF using the original text-based bookmark names, the output files will likely lose their original chronological order. To prevent this, you must append sequential numbers to the bookmarks before the splitting process.
Open your PDF in an advanced PDF editor (such as Adobe Acrobat) and navigate to the Action Wizard or JavaScript console.
Execute a JavaScript snippet that loops through bookmarkRoot.children. The script should calculate the necessary prefix length based on the total number of bookmarks and rename each using a zero-padded sequence (for example, using util.printf to add '01_', '02_', etc.).
Add a Save command to your batch action, or manually save the PDF document to ensure the new sequential bookmark names are permanently applied.
Use the 'Split Document' feature in your software, select the option to split by 'Top-level bookmarks', and choose to use the bookmark names as the output filenames.

Split and Manage PDF Pages Easily with WPS Office
WPS PDF provides an intuitive and powerful interface to extract, split, and manage PDF pages without the need for complex JavaScript codes. You can effortlessly split large documents, organize your files visually, and rename sections manually.
- 1. Open your PDF in WPS Office: Launch WPS Office on your computer and open the large PDF document you want to divide.
- 2. Access the Split PDF Tool: Navigate to the 'Page' tab on the top menu ribbon and click on the 'Split PDF' button.
- 3. Configure your Split Settings: Choose your preferred splitting method in the dialog box (such as splitting by custom page ranges) and select your desired output folder.
- 4. Extract and Save: Click the 'Split' button to instantly separate your large document into smaller, sequentially ordered files.

Frequently Asked Questions
Why are my split PDF files out of order in Windows Explorer?
Windows Explorer sorts files alphabetically or numerically based on the filename. If your original PDF bookmarks started with letters instead of numbers, Windows will sort the extracted files alphabetically, disrupting the document's original reading order.
Can I rename bookmarks manually instead of using a JavaScript?
Yes. If your document only has a few top-level bookmarks, you can right-click each bookmark in your PDF editor's bookmark panel, select 'Rename', and manually type '01_', '02_', etc., before executing the split command.
Does zero-padding matter if I have fewer than 10 bookmarks?
If you are absolutely certain you will never exceed 9 bookmarks, standard numbering (1, 2, 3) works. However, using zero-padding (01, 02) is a best practice, as Windows will sort '10' right after '1' if the zero is missing, breaking the sequence.
Will splitting a PDF by bookmarks reduce the quality of the text or images?
No. Splitting a PDF by bookmarks simply extracts the existing pages into separate files. The original resolution, text formatting, and image quality of the document are perfectly preserved in the output files.




