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">
      <param>--visualizer</param>
      <param>--part=sep:"five"</param>
      <param>--format=images</param>
      <param>--imgformat=PDF</param>
      <param>--sep_colors</param>
      <param>--resolution=300</param>
      <param>--compression=PDF_Flate</param>
      <param>--outputfolder="%TEMP_FOLDER_1%"</param>
      <param>"%INPUT_FILE%"</param>
   </step>
   <step type="callas">
      <param>--slice</param>
      <param>--outputfolder="%TEMP_FOLDER_1%"</param>
      <param>"%ASSETS_FOLDER%Slice to CUT.kfpx"</param>
      <param>"%INPUT_FILE%"</param>
   </step>
   <step type="callas">
      <param>--slice</param>
      <param>--outputfolder="%TEMP_FOLDER_1%"</param>
      <param>"%ASSETS_FOLDER%Slice to white.kfpx"</param>
      <param>"%INPUT_FILE%"</param>
   </step>
   <step type="callas">
      <param>--overlay</param>
      <param>"%TEMP_FOLDER_1%%INPUT_FILE_NAME%_2.pdf"</param>
      <param>"%TEMP_FOLDER_1%%INPUT_FILE_NAME%_0001_sep_five.pdf"</param>
      <param>-o="%TEMP_FOLDER_1%out.pdf"</param>
   </step>
   <step type="callas">
      <param>--mergepdf</param>
      <param>"%TEMP_FOLDER_1%%INPUT_FILE_NAME%_0001.pdf"</param>
      <param>"%TEMP_FOLDER_1%out.pdf"</param>
      <param>-o="%TEMP_FOLDER_1%out1.pdf"</param>
   </step>
   <step type="callas">
      <param is_kfpx="true">"%ASSETS_FOLDER%Labels Whiteink Proof V8.0.kfpx"</param>
      <param>"%TEMP_FOLDER_1%out1.pdf"</param>
      <param>-o="%OUTPUT_FILE%"</param>
   </step>
</kfpy>

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.


Syntax

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_FILE_2%
%TEMP_FILE_3%
%TEMP_FILE_4%
%TEMP_FILE_5%
%TEMP_FILE_6%
%TEMP_FILE_7%
%TEMP_FILE_8%
%TEMP_FILE_9%
%TEMP_FILE_10%
%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.
%TEMP_FOLDER_2%
%TEMP_FOLDER_3%
%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.
 
 
 
 
Debug
 
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];
    }