Extract(copy) 1st two pages of output to folder

I have a workflow that takes a text file and outputs a merged multi-page pdf file. The workflow works well creating the 9 page pdf documents. What I now need to do is send a copy of the first two pages to a folder. I know I could create another branch or process and use a 2nd template configuration. It just seems that since I already have the content created, there is a more efficient way to do this. Does anyone know how this might be accomplished?

Use the following script. It extracts the first 2 pages of the job file (which is assumed to be your 9-page PDF files) and saves them as a new file (you’ll have to change the destination name, obviously):

var myPDF = Watch.GetPDFEditObject();
myPDF.Open(Watch.GetJobFileName(),false);
myPDF.Pages().ExtractTo('C:\\Tests\\FirstTwoPages.pdf',0,2,true);
myPDF.Close();

Phil,

Thanks so much for the reply. Where is the best node to place the script? I used the run script and get an “error 0 on line 1”

Thanks again.

Phil,

Figured out the issue. Running on weekend brain. Just had to change language. I do have another question though. Each pdf has a unique name. How would I name each of the new files with the original filename within the script?

Change the ExtractTo() line to:

myPDF.Pages().ExtractTo('C:\\Tests\\'+Watch.ExpandString('%O-%u.pdf'),0,2,true);

%O is the original file name without extension, then we add %u which is a unique, random 15 character string that ensures no two files will get the same name.

Worked perfectly! Thanks for your help!