Setting boundary using script

Hi

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?

Please give us an examples of the file names and what you need to achieve for each one, and then we can help you out.

Yeah it’s for example TestFile_1.pdf

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

Hi Phil,

I’ve used this but it seems to break it as it just changes to this so looks like no records? Where as before I could see the input PDF

Check the Messages panel. There are probably errors reported in there.

Hi,

Yeah thanks phil, was my mistake, named the field incorrectly.

Big thanks for your help with this.

James