Hi,
I wonder if there is a possibility to set the jobfile within a script. I know about the possibility to read and write the jobfile via filesystem object but what about binary data (e.g. pdf)?
I want to create/change a pdf via alambic and set the new/changed pdf as jobfile without saving it in script and afterwards loading it in an extra workflow step.
I have workflow processes where I have to crop a pdf and set it on a new empty pdf with bigger size than the cropped one.
Currently I have two script steps (both Alambic):
In the first step I crop my input pdf (from A4 to 40x40mm) and save the new pdf in a temp folder.
In the second step I create a new pdf in 100x100mm and place my cropped pdf on it (merge it on the new pdf), save the new pdf in the temp folder and in the next process step I load that pdf as jobfile.
Is there a way to do that in one script step, without saving and loading several temp pdfs?
Is it that simple? I thought I have to create a new pdf with my new size and insert/merge the content from my job file pdf to that new pdf object and save that.
How can I change the page size of my job file pdf in Alambic directly?
Lets say I have a pdf in 40x40mm (see image below). I want to crop it to 20x20mm but not only from bottom left.
In the below image I want to get only the green area.
Here’s a sample script that reads the job file (a PDF), adds a new page to it with a smaller media size, copies the first page onto the smaller, newly added page, and then deletes the first page so that all that remains in the job file is the new, cropped page.
var input = Watch.GetPDFEditObject();
input.open(Watch.GetJobFileName(),false);
var sourcePage = input.pages().item(0);
var mediaSize = new ActiveXObject("AlambicEdit.PdfRect");
mediaSize.left = 0;
mediaSize.bottom = 0;
mediaSize.top = 84;
mediaSize.right = 184;
input.pages().insert(1,mediaSize);
var destinationPage = input.pages().item(1);
destinationPage.merge2(sourcePage,-129,-219,0,1);
sourcePage = null;
destinationPage = null;
mediaSize = null;
try {
CollectGarbage();
input.pages().Delete(0);
input.save(false);
input.close();
} catch (e) {
// do nothing
}
Note that a large portion of the code is simply for getting around a garbage collection issue in JScript.