I have a job where I want to split documents by page but based on the input filename. It’s coming through workflow so I can get this passed into a data mapper no problem but how can I split based on this value? I’m guessing I can use a script but not sure what script I need?
I’ve got the page split from teh filename within workflow and passing that down in a automation variable. I’ve created the below script but it doesn’t seem to be working. Do I need to define the boundary variables somewhere?
//get current page counter and increment
var PageCount = boundaries.getVariable(“PageCount”);
PageCount++;
//get split value from automation variable
var PageSplit = automation.variables._PageSplit;
//do a modulus on the inut page and page split, if 0 then set back boundary
if(PageCount%PageSplit == 0){
boundaries.set();
}
//set value back for use later
boundaries.setVariable(“PageCount”,PageCount);
All right, so you are receiving the number of pages to split on in the _PageSplit automation variable.
Your code should therefore look something like this:
var PageSplit = automation.variables._PageSplit || 1; // Set default value to 1 in case variable is missing
var curPage=0;
if(boundaries.getVariable("lastValue")==null) { // Check if boundary variable was already created
boundaries.setVariable("lastValue",curPage); // if not, create it
} else {
curPage = boundaries.getVariable("lastValue"); // Set CurPage to value in variable lastValue
curPage ++; // Increment by 1
}
if((curPage % PageSplit)==0){ // Check if we need to set the boundary
boundaries.set();
}
boundaries.setVariable("lastValue",curPage); // Store curPage value in lastValue