Skip to main content
Participant
March 2, 2019
Answered

JavaScript - Split large PDF into separate files based on text inside PDF

  • March 2, 2019
  • 1 reply
  • 7258 views

I have Adobe Pro 11

I want to split a large Pdf file 2550 pages into multiple files with JavaScript.

The text '"Subtotal" only exists on these divider pages, so it can be used to identify where to split the document.

How easy would it be to create some javascript to run in an action which would do the following:

1. Identify text "Subtotal"

2. Split document at that point, saving the pages from current page (typically 5, though not always) up to page before next instance of "Subtotal"

Can this be done, or has it been done already? Thanks

This topic has been closed for replies.
Correct answer Thom Parker

Yes, this sort of thing has already been done.

Use the "doc.getPageNthWord()" function to find your keyword.  Then use the "doc.extractPages()" function to split out the pages.  Not difficult if you know how to program.  

You can look up these functions in the Acrobat JavaScript Reference here:

Acrobat DC SDK Documentation

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
March 2, 2019

Yes, this sort of thing has already been done.

Use the "doc.getPageNthWord()" function to find your keyword.  Then use the "doc.extractPages()" function to split out the pages.  Not difficult if you know how to program.  

You can look up these functions in the Acrobat JavaScript Reference here:

Acrobat DC SDK Documentation

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often