Using Quick Check as a step in a Process Plan
When creating or editing a Process Plan, it is possible to insert a Quick Check step in the Process Plan.
For the purpose of this article, a new Process Plan is created:
Add Quick Check:
- In the top left field you can enter a suitable name for the new Process plan
- Select "Quick Check" from the "Sequence" list on the right and drag this step onto the area of the Process plan editor
- Delete the default connection type between "Start" and "End" (dashed line) and connect "Start" with "Quick Check" and "Quick Check" again with "End" (as shown below)
The Quick Check step has now been inserted into the process plan as an element.
- In order to set up what the Quick Check step should contribute as a result, either a suitable Quick Check JavaScript variable is selected from the "Name" drop-down menu,
- or a new Quick Check JavaScript variable is created using the "+" symbol (explained below).
New Quick Check JavaScript variable
When creating a new Quick Check-JavaScript variable, the Edit Quick Check window is opened, as shown below.
- Enter suitable value for the "Key" (by which the variable can be referenced in the
app.vars
object) - Enter suitable value for the "Label" (shown in the user interface when displaying a reference to the variable)
- Edit the "Script" (what is shown above is the default script that requests the TrimBox for all pages)
- To view the list of all Quick Check objects, click 'i' and 'Insert Quick Check objects' (a new window opens that is shown below)
- The "Test" button will open the "Test profile" window which shows the output of the Quick Check Variable (here the size of the TrimBox)
After inserting the required Quick Check object, click OK to save this Quick Check-JavaScript variable, and click OK again to save the new Process Plan.
Whenever this Process Plan is executed, the TrimBox of all pages gets stored in the app.vars
object under quickcheck_1
.
Obviously, in this simple form the Process Plan is not very useful. The next part of the article shows a slightly extended variant of this Process Plan, that actually makes some interesting use of the information retrieved by the Quick Check step.
After entering a suitable name for the new Process Plan, select "Quick Check" from the "Sequence" list and click on the "Add" button in that list entry:
A new "Quick Check" step gets inserted as the first item in the list of Process Plan steps.
- In order to configure what the "Quick Check" step is to provide as a result, either a suitable Quick Check-JavaScript variable has to be chosen in the "Name" popup list,
- or a new Quick Check-JavaScript variable has to be created using the "+" icon.
How to use information retrieved by a Quick Check step in a Process Plan
In order to try out the Process Plan presented below, please download it here:
After importing the downloaded "Quick_Check_example.kfpx" file and importing it into pdfToolbox Desktop, it should show up as can be seen below:
In order to explore how this Process Plan has been constructed, click on the "Edit..." button next to the "Quick Check example" entry.
The "Edit Process Plan" dialog will open. It contains two steps:
- Quick Check step using a variable named "quick_check_sample_JavaScript_variable" that collects information from the current PDF
- Fixup step "Put file name and file path on upper left of all pages" that picks up the collected information and uses it to place text on each page of the current PDF
In order to have a look at the way the JavaScript variable has been set up,
- click on the Edit button to the right of the "Name" popup.
Alternate image for the older Process Plan UI:
The "Edit Variable" window will open, revealing the setup of the variable "quick_check_sample_JavaScript_variable".
The relevant part of the configuration are these two lines:
"$.aggregated.file.name: true ",
"$.aggregated.file.filepath: true ",
which request that Quick Check retrieves information about the file name and the file path of the current PDF. For a detailed description of the configuration set up please check out the article Quick Check configuration syntax.
Close the "Edit Variable" window, and thus go back to the Edit window for the Process Plan.
- Click on the Edit icon to the right of the Name entry for the Fixup step.
Alternate image for the older Process Plan UI:
The "Edit Fixup" window for the "Put file path and name on upper left of all pages" Fixup will open.
The numerous fields in this Fixup are filled with values that will make the contents of the "Text" field show up in the upper left of all pages of the current page using Courier font in pink spot color.
The more interesting part of this Fixup at least in this context is how the contents of the "Text" is defined.
- Click on the orange triangle popup to the right of the "Text" field.
A list of already defined variables is now shown, plus various options regarding existing or new variables.
- Click on 'Edit "place_filepath_text"...'
The "Edit Variable" window for the variable "place_filepath_text" will open.
Important: this not the same variable as the JavaScript variable defined in the QuickCheck step (which configures that Quick Check step), rather, it is a separate JavaScript variable that makes use of the information retrieved by the Quick Check step.
As that information will only be available if the Fixup gets executed as part of a Process Plan, where in a previous step a suitable Quick Check step has been executed. Some precautions are taken in the JavaScript code that give a kind of error message "filename @ filepath: WARNING: required variables undefined" if the Fixup is executed on its own or in a different Process Plan or Profile. This is managed by the if
branch of the JavaScript code:
if (
typeof app.vars.my_quickcheck_example == 'undefined' ||
typeof app.vars.my_quickcheck_example.aggregated == 'undefined' ||
typeof app.vars.my_quickcheck_example.aggregated.file == 'undefined' ||
typeof app.vars.my_quickcheck_example.aggregated.file.filepath == 'undefined' ||
typeof app.vars.my_quickcheck_example.aggregated.file.name == 'undefined'
)
{
var myvar = "filename @ filepath: WARNING: required variables undefined";
}
The intended main portion of the JavaScript variable is contained in the else
branch:
else {
var myvar = "filename: «"
+ app.vars.my_quickcheck_example.aggregated.file.name
+ "»<br/>filepath: «"
+ app.vars.my_quickcheck_example.aggregated.file.filepath
+ "»" ;
}
This else branch creates a string built from two variables, app.vars.my_quickcheck_example.aggregated.file.name
and app.vars.my_quickcheck_example.aggregated.file.filepath
, concatenated with other bits of text into a nicely formatted string.
After closing this "Edit Variable" window, and then also the "Edit Fixup" window, the "Edit Process Plan" window will be shown again. Instead of also closing this window and trying the Process Plan on one of your files,
- use the "Test" feature by clicking on the "Test" button
Alternate image for the older Process Plan UI:
This will open the "Test profile" window – a very convenient environment to try Process Plans (or Profiles, Fixups and Checks) on a copy of a currently open PDF file without the risk of inadvertently breaking your files ("Test" processing is always carried out on temporary copies of your PDF files), and without tedious open/edit/close/apply cycles, and without any need to clean up processed copies of your PDF files.
As you can see in the screen shot some text is showing up in the upper left of the sample file used here (a PDF consisting of an empty A 4 sized page, and named accordingly).