Using Process Plans in Process Plans to loop over pages

Why looping over pages?

Normally Fixups and Checks work just fine for multi-page PDFs. That is even the case if pages are very different, e.g. when their page sizes differ. All Fixups, where that is relevant, can be set up to work according to the current page size (page geometry box size). However, that is not always the case. E.g. if you want to add different objects to each page or if you want to use the current Trim Box in JavaScript you may want to process each page individually. That was aways possible in Process Plans using JavaScript, but it becomes much easier with pdfToolbox 16.

Example

As an example we want to place an ink amount visualization on each page of a PDF file. The Process Plan below does that for a single page in a PDF file. A variable is used to specify that page.

(erliest version with full support is pdfToolbox 16)

Screenshot of the Process Plan editor showing all the individual steps of the "Add ink coverage visualization" Process Plan

The Process Plan creates an ink coverage visualization for the specified page, gets the file path from the JavaScript object, adds 10cm at the bottom of the specified page and places the ink amount visualization in that area.

It would not be impossible to do this for all pages of a document using the "Place content" technology, but it would be a complex task to create a proper template.

Applying a Process Plan to each page individually using a parent Process Plan

It is much easier but a little slower to do that using a parent Process Plan.

Erliest version with full support for “Add ink coverage visualization on all pages.kfpx” is pdfToolbox 16

Screenshot of the parent process plan that has the child process plan as its only step

In the parent Process Plan there is a "Process each page individually (loop)" checkbox (1). If that is active the PDF is provided to the child Process Plan several times, depending on the number of pages in it. That of course slows down processing, but allows you to process the PDF page by page achieving things that would otherwise be much more complex.

In the child Process Plan you then have to make sure that only the current page is processed. There are two tools that make that more convenient:

With (2) 'Auto set "Preflight only pages" in child steps' the parent Process Plan automatically sets all steps in the child Process Plan that have a "Preflight only pages" input field to use a variable for the current page. This input field is available for all Check, Fixup and Profile steps in the child Process Plan.

With (3) you can specify a variable that is set to the current page number.

In our example, we are using the variable "currPage" to tell the Action in the child Process Plan that creates the ink amount visualization which page to process. We use the same variable for the two Fixups in there, although that would not be necessary with the 'Auto set "Preflight only pages" in child steps' checkbox. But this way we can also use the child process plan directly.

One thing to note is that the "'Current page' variable" is 1 based while the page geometry boxes array in JavaScript is 0 based. So, if you want to use the current page variable in the JavaScript of the child Process Plan you will have to subtract 1.