I have some large PDF’s of invoices I would like to split into smaller files. They need to be split on the beginning of a customer invoice. I have a script for finding the beginning of an invoice in vbscript and I have a script for extracting pages from the PDF based on start and stop page, but it is in javascript. Wondering if anyone could give me the equivalent command from one language to the other so I can get this done with one script.
Here’s what I have for finding the beginning of the invoice
if instr(myPDF.Pages.Item(i).ExtractText2(7.6146, 10.5833, 8.3438, 10.7188)," 1 of") > 0 then
And here’s what I have for extracting the pages to a new pdf.
mypdf.Pages.ExtractTo(splitname,startpage,splitend-1,true);
Couple of things to note: JavaScript’s indexOf() is 0-based, so that why we use >=0 in the comparison. Also, JS is case sensitive, so myPDF is not the same as mypdf. Make sure to adapt your scripts accordingly.
Either you are running an old version of Workflow, or you haven’t set your Script Language to use Enhanced JScript (which supports the trim() method, whereas regular JScript doesn’t).
The feature was introduced in Connect 2019.2.
To set the language to Enhanced JScript, open your script task and select the Enhanced JScript option from the Language menu.