Process pages differently in a Process Plan using a Check and JavaScript
It is possible to process pages differently depending on the result of a Check (or a Profile). In this article we are using a Process Plan that first identifies pages that are portrait (and not landscape). These pages are then stamped and rotated.
The Process Plan uses 4 steps.
If you need one to try out this is a PDF with portrait and landscape pages.
Page is portrait
The first step "Page is portrait" checks whether there are any such pages, if not (on success) the Process Plan is immediately terminated. If there are such pages (on hit) a JavaScript step is executed. Since pdfToolbox updates it's JavaScript object after Checks this object now has information which pages are portrait. The JavaScript takes this result object and converts it into a comma separated page list.
Create page list
For each item in the result object the script extracts the page number, adds 1 (because in the result object page numbers are 0 based) and appends it to the page list. Finally the page list that has been created in the script is written into a global variable app.vars.pages.
Place text "Portrait"
The next step places a stamp "Portrait" on the respective pages. The page list that had been created in the previous step and saved into app.vars.pages is now used in the page filter "Preflight only pages" for the Fixup.
Rotate pages -90
The next and last step then rotates the pages from the page list. "Rotate pages -90" is based on a Quick Fix since that is faster than the corresponding regular Fixup. A Quick Fix always has it's own page selector, so we do not use the Process Plan sidebar, but a Quick Fix parameter.