How to Automatically Extract and Split Variable-Page Invoices from a Single PDF
Question details
The user needs an automated method to separate a large, single PDF file containing multiple invoices of varying page lengths into individual document files.

- Product
- PDF Editors
- Device & OS
- not provided
- Scenario
- Processing bulk invoices contained in a single PDF file where each customer invoice spans a different number of pages.
- Observed behavior
- Standard PDF splitting tools typically divide documents by a fixed page count, which fails to accurately separate variable-length invoices, cutting them off in the middle.
Before attempting to split the file programmatically, carefully review your PDF to identify a consistent text pattern or marker (such as 'Invoice Number:' or 'Page 1 of') that reliably indicates the start of a new invoice.
Use Custom Acrobat JavaScript to Split by Text Identifiers
Utilize custom JavaScript to scan the document for specific text markers and programmatically extract pages of variable lengths.
Because standard split tools rely on fixed page counts, processing variable-length documents requires a dynamic approach. By writing a custom script, you can instruct the software to scan each page for a unique identifier that only appears at the beginning of an invoice. Once identified, the script uses the extractPages() function to slice the document exactly where one invoice ends and the next begins.
Open your PDF and locate a consistent text string that appears exclusively on the first page of every invoice, such as 'Invoice Number:'.
Navigate to the Tools menu in Adobe Acrobat and select 'Action Wizard' to begin creating a new custom action.
Add a custom script step that iterates through the document pages, searches for your identified text marker, and triggers the this.extractPages() function to split the sections.
Save and execute the newly created action on your batch PDF file to automatically generate and save individual invoice documents.

Split Invoices by Top-Level Bookmarks
If the source system generated the bulk PDF with bookmarks for each invoice, you can use built-in tools to split the document along those bookmarks.
Organize and Split Invoices Easily with WPS Office
WPS Office provides an intuitive PDF editor that allows you to visually organize, extract, and split pages. Whether you are splitting by custom page ranges or extracting specific sections, you can quickly separate multiple invoices into independent files without complex coding.
- 1. Open the PDF in WPS Office: Launch WPS Office and open your multi-invoice PDF file.
- 2. Navigate to the Split Tool: Go to the 'Page' tab on the top ribbon and click on 'Split PDF'.
- 3. Set Custom Page Ranges: Select the 'Custom split' option to manually define the specific variable page ranges for each invoice.
- 4. Save Individual Invoices: Choose your desired output folder and click 'Split' to generate your individual invoice documents.

Frequently Asked Questions
Why can't the standard 'Split Document' tool handle my invoices?
Standard split tools usually divide files by a fixed number of pages or a specific file size. Since variable-length invoices have different page counts (e.g., one invoice is 2 pages, the next is 5), a fixed split will cut invoices in the wrong places.
Can I split a PDF automatically without using JavaScript?
Yes, if the PDF is pre-formatted with top-level bookmarks for each invoice, most advanced PDF editors allow you to split the document automatically based on those bookmarks without writing any code.
What text identifiers work best for automated script splitting?
It is best to use unique and consistent markers that only appear once per invoice. Reliable examples include 'Invoice Number:', 'Account No.', or 'Page 1 of'.
Is there specialized software for batch invoice splitting?
Yes, there are dedicated OCR and data extraction tools designed specifically for accounts payable. These tools can intelligently recognize invoice boundaries and split them automatically, bypassing the need for manual scripting.




