Extract two pages from a multi-page PDF and rename it based on matching string using Regex.
Hi all, I am using Adobe Acrobat Pro 2017 and I am trying to extract every two pages of a multi page PDF. The two pages that are extracted have an ID that can be searchable if all words in the document are put into a string. I have created similar code that works, but it is supposed to extract every page and rename it the first 8 digit code it can find using regular expressions. Take a look at the below code and let me know what you thing. Thanks!
/* Extract 2-page funding notice */
// Regular expression used to acquire the base name of file
var re = /\.pdf$/i;
// filename is the base name of the file Acrobat is working on
var filename = this.documentFileName.replace(re,"");
for (var i = 0; (i * 2) < this.numPages; i++) { // Loop through the entire document
numWords = this.getPageNumWords(i); // Find out how many words are on the page
var WordString = ""; // Prepare a string
for (var j = 0; (j < numWords; j++) // Put all the words on the page into a string
{WordString = WordString + " " + this.getPageNthWord(i, j);}
ID = WordString.match(/\b\d{8}\b/); // Search for the 8 digit ID control # in the string
this.extractPages({
nStart: i * 2,
nEnd: (i * 2) + 1,
cPath: "/J/myfilepath/" + "SBIC_" + ID +"-Fnew.pdf"
});
} This code does run, however, not how I want it to. It pulls the first 8 digit ID in the string and the last two pages of the document.
