Is there a simpler way to remove a particular page from a pdf input?
For example if I do folder capture to pick up any PDF files in workflow, now I want to output it back to a folder but without the 2nd page but only the remaining ones as 1 pdf file. How would I do this?
Thank you for any help or steer to the right direction.
Kind regards,
E
Okay, what I did is added a PDF splitter and have an if branch text condition testing for %i == 1 (second page) and goes to delete and the rest sends to folder with concatenate file turned on.
In case you would like to remove the second page from two page PDF documents you can use a Run Script Workflow plugin instead and apply the following JavaScript code to this Run Script Workflow plugin:
var pdfIn = Watch.GetPDFEditObject();
var pdfOut = Watch.GetPDFEditObject();
pdfIn.Open(Watch.GetJobFileName(), false);
pdfOut.Create(Watch.GetJobFileName() + ".copy.pdf");
// https://help.uplandsoftware.com/objectiflune/en/pres_workflow/2023.1/Workflow/Alambic_API/IPages_Methods.html#InsertFr2
pdfOut.Pages().InsertFrom2(pdfIn.Pages(), 0, 1, 0);
pdfOut.Save(true);
CollectGarbage();
pdfOut.Close();
pdfIn.Close();
var objFso = new ActiveXObject("Scripting.FileSystemObject");
objFso.DeleteFile(Watch.GetJobFileName());
objFso.CopyFile(Watch.GetJobFileName() + ".copy.pdf", Watch.GetJobFileName());
The above JavaScript code is based on the JavaScript code shared via this OL Learn forum post.
NOTE: Make sure to change the Language of the Run Script Workflow plugin to JScript before applying the above JavaScript code.