KFPY scripts

General info

KFPY scripts are special type of scripts used in place of Callas KFPX scripts in tFLOW. The difference is that KFPY scripts are actually “compound” scripts - they allow to run several KFPX scripts in sequence, optionally passing outputs of one KFPX script to input of another one. Additionally, KFPY scripts support features like running arbitrary program, moving files, copying files or make a direct pdfToolbox call passing all the needed paramters.

Basically KFPY scripts are XML files. Here is an example of a KFPY script:

<?xml version="1.0" encoding="UTF-8"?>
<kfpy version="1">
   <step type="callas">
   <step type="callas">
      <param>"%ASSETS_FOLDER%Slice to CUT.kfpx"</param>
   <step type="callas">
      <param>"%ASSETS_FOLDER%Slice to white.kfpx"</param>
   <step type="callas">
   <step type="callas">
   <step type="callas">
      <param is_kfpx="true">"%ASSETS_FOLDER%Labels Whiteink Proof V8.0.kfpx"</param>

Note that the KFPY script above has six steps, and they all use different parameters and substitution variables.
On the last step the system executes a regular kfpx profile.

All the kfpx profiles referenced by any KFPY file must be loaded into the "Auxiliary scripts" folder in the Automation Assets area.


The metatag must specify UTF-8 encoding. The root tag must be always <kfpy> and must have version attribute, which specifies the version number of the KFPY file structure. Currently supported version is 1.

Step types

Step: Callas

tag name Is mandatory? Description
param no Parameter to pass to Callas. There can be more than one param tag. One of the params tag may have is_kfpx=“true”attribute. In that case, the parameter must reference to an existing KFPX file, and the system will try to extract profile variables from that file. Also, when executing Callas on that step, the system will add RSP file to the end of the command line, passing values of profile variables.

Note that merging of PDF nor XML reports from different Callas steps are not performed, so only one Callas step can produce reports of the whole KFPY script.

Also note that only one param tag in each step can have is_kfpx=“true” attribute.

Step: Rename

tag name Is mandatory? Description
source yes Full path to file to be renamed
target yes New name for the file. May contain path, in that case the file will be moved to the new location.

Step: Copy

tag name Is mandatory? Description
source yes Full path to file to be copied
target yes New name for the file. May contain path.

Step: Program

tag name Is mandatory? Description
program yes Name of the operational system program to run.
param no Parameter to pass to the program. There can be more than one param tag.


Supported substitution variables

KFPY scripts support a set of substitution variables which can be used in values of all tags. The basic syntax is the same as for Variable Substitution Engine, but the set of variables is different.

Variable Meaning
%TEMP_FILE_1% These variables reference to temporary files. These files are created on demand and deleted at the end of the script. So, for example %TEMP_FILE_1% variable will be expanded to the same file name on every usage in given script. This is useful for intermediate results, so that outputs from one step can be passed to input of another step.
%TEMP_FOLDER_1% These variables reference temporary folders. The approach is the same as for temporary files: they are created on demand and deleted at the end of the script.
%INPUT_FILE% References to the input PDF for the script.
%INPUT_FILE_NAME% Expands to a name of the input PDF for the script. The difference from the %INPUT_FILE% variable is that it contain full path to the input file, while %INPUT_FILE_NAME% contains only the file name, without path and extension. This is usable for creating intermediate files sometimes generated by Callas in temporary folder.
%OUTPUT_FILE% References to the output PDF for the script.
%XML_REPORT_FILE% References to the resulting XML report file for the script. The meaning is the same as –report=XML,path=… when running Callas.
%PDF_REPORT_FILE% References to the resulting PDF report file for the script. The meaning is the same as –report=TEMPLATE=…,path=…when running Callas.
%ASSETS_FOLDER% References to *Auxiliary Scripts* folder in Automation Assets manager. Note that the expanded value contains trailing path delimiter.
Pluggable storage
With the pluggable storage, there are no local paths because all files are stored in a cloud. Because of that, the %ASSETS_FOLDER% substitution variable has been removed.
Now, instead of writing this:
<param is_kfpx="true">"%ASSETS_FOLDER%PCIGrafx Normalize White.kfpx"</param> 
we should write this
<param is_kfpx="true" is_aux_script="true">"PCIGrafx Normalize White.kfpx"</param> 
So, if a param tag has attribute is_aux_script equal to true then tFLOW will look for the specified file in the Auxiliary Scripts folder, download it from the cloud if needed, and use when executing Callas.
To debug a kfpy script is useful to not automatically delete the Temp files.
Keeping them in the system helps to see the correct partial result creations and alterations.

To do this, edit
app\lib\Tethra\AutomationScript\KfpyScript.php in line 139
change getTempFolder() to makeTempFolder()
    public function getTempFolder($number)
        if( !array_key_exists($number, $this->tempFolders) )
         /*   $this->tempFolders[$number] = getTempFolder();*/
  $this->tempFolders[$number] = makeTempFolder();
        return $this->tempFolders[$number];