tFLOW Documentation - 07b. Substitution Variables

tFLOW > tFLOW Documentation

Concept

A script (kfpx file) may contain substitution variables, which are replaced by actual values during processing. Substitution variable name is a text between percent signs '%'. To prevent misinterpretation, two escape sequences are supported when processing:

  • \% is replaced by %
  • \\ is replaced by \

Variable name consists from several parts separated by points. First (leftmost) part is the object name. Supported object names are:

  • job - references to the job
  • client - references to the client to which the job belongs
  • order - references to the order to which the job belongs
  • revision - references to the current revision on the job

Second part is a sub-object name or attribute name. For sub-objects, there are some attributes defined, depending on the sub-object type.

  • for jobs and orders, there is props sub-object
  • for revisions, there is pdfInfo sub-object

As long the syntax is correct, all variables yield valid strings. If a variable references to a not existing property, it yields an empty string. 
If the syntax is not correct, then the variable will yield a corresponding error message.

The script editor in tFlow has a specific section where is possible to enter the variable settings:

 
Formatting
Inside percent signs, after the variable name, a format specification can be added. There are two types of format specifications.

ExampleNumbers and strings formatting
%job.props.print_height|.3d%
See PHP sprintf() documentation for full description of possible format strings.
Note that:
  • The format specification doesn't include leading % symbol
  • An additional format type is added:
    • 't' - if precision is not specified, then it works identical to 's', else trims to the precision with adding ellipsis to the end of the string.
  • A start offset can be specified before the format string in the following form: 20:.10s. Note that the start offset can be specified only for 't' and 's' format types. If the start offset is greater than the argument's length, then the output will be empty.

Example of Date and time formatting
%job.ship_date|m-d-Y%
The previous example will yield “01-20-2016” assuming that the ship date is 20 January 2016. Full description of possible format strings can be found here.
 
Other examples on formatting
Template
Value of the variable
Result
Notes
%job.props.quantity|.5d%
123
123
Note the two spaces to the left of 123. That is because the format specified the field width of 5 symbols.
%job.description|.10t%
20 characters length
20 char…
Note the output is exactly 10 symbols wide, with ellipsis … added at the end.
%job.props.height|.5f%
0.0012345
0.00123
Note that the output is rounded up to 5 decimal digits.
%job.ship_date|\%l \t\h\e jS%%
2016-01-20 16:10
Wednesday the 20th
Note that for dates, the formatting should be always specified, like this:
 %job.ship_date|m/D/Y%

List of available variables

Referencing the job
Name
Description / Notes
job.name
 
job.description
 
job.kfpx
Preflighting profile
job.notes
 
job.ship_date
This variable is of type DateTime, so, the suitable format strings must be used.
job.start_date
This variable is of type DateTime, so, the suitable format strings must be used.
job.product.name
The product name assigned to this job
job.props
This sub-object contains values of defined dynamic properties. Currently, default dynamic properties for jobs are:
  • email_contact
  • min_ppi
  • mis_contact
  • mis_job_number
  • phone_contact
  • pm_name
  • print_height
  • print_width
  • quantity
  • rep_name
  • sales_rep
  • shipping_address
job.props.printWidthMm
Value of print_width dynamic property converted to millimeters.
job.props.printHeightMm
Value of print_height dynamic property converted to millimeters.
job.props.printWidthInches
Value of print_width dynamic property converted to inches.

Referencing the order
Name
Description / Notes
order.name
 
order.description
 
order.product.name
The product assigned to the order
order.notes
 
order.ship_date
This variable is of type DateTime, so, the suitable format strings must be used.
order.start_date
This variable is of type DateTime, so, the suitable format strings must be used.
order.props
This sub-object contains values of defined dynamic properties. Currently, default dynamic properties for orders are:
  • min_ppi
  • pm_name
  • print_height
  • print_width
  • rep_name
order.createdBy.name
Name of the user who initially created the order
order.createdBy.email
Email of the user who initially created the order
 
 
Referencing the client
Name
Description / Notes
client.name
Name of the client



Referencing the revision
Name
Description / Notes
revision.original_filename
 
revision.ordinalNumber
The ordinal number of the revision within the job.
revision.pdfInfo.pages.count
Number of pages.
revision.pdfInfo.pages.XXX.formattedPrintSize
The format is the same as for job.formattedFinalSize. XXX should be substituted with the page number. Note that pages are numbered from 1, not from 0.
revision.pdfInfo.pages.XXX.formattedMediaboxSize
Size of the mediabox.
revision.pdfInfoInches.pages.XXX.formattedMediaboxSize
Size of the mediabox in inches.
revision.pdfInfoMm.pages.XXX.formattedMediaboxSize
Size of the mediabox in mm.
revision.pdfInfo.pages.XXX.formattedCropboxSize
Size of the cropbox.
revision.pdfInfoInches.pages.XXX.formattedCropboxSize
Size of the cropbox in inches.
revision.pdfInfoMm.pages.XXX.formattedCropboxSize
Size of the cropbox in mm.
revision.pdfInfo.pages.XXX.formattedTrimboxSize
Size of the trimbox.
revision.pdfInfoInches.pages.XXX.formattedTrimboxSize
Size of the trimbox in inches.
revision.pdfInfoMm.pages.XXX.formattedTrimboxSize
Size of the trimbox in mm.
revision.pdfInfo.pages.XXX.formattedBleedboxSize
Size of the bleedbox.
revision.pdfInfoInches.pages.XXX.formattedBleedboxSize
Size of the bleedbox in inches.
revision.pdfInfoMm.pages.XXX.formattedBleedboxSize
Size of the bleedbox in mm.
revision.pdfInfo.filename
Same as revision.original_filename
revision.pdfInfo.pdf_version
 
revision.pdfInfo.filesize_bytes
Size of the file in bytes
revision.pdfInfo.title
 
revision.pdfInfo.author
 
revision.pdfInfo.creator
 
revision.pdfInfo.producer
 
revision.pdfInfo.colors.count
Number of colors defined in the PDF file.
revision.pdfInfo.colors.0 ... revision.pdfInfo.colors.N
Color names as they defined in the PDF file, where N is a numeric index started from 0. If there is no color with such index, then the substitution variable yields empty string.
revision.pdfInfo.pdfxversion
 
revision.pdfInfo.trapped
 
revision.pdfInfo.totalpages
Nuber of pages. Same as revision.pdfInfo.pages.count.
revision.pdfInfo.used_kfpx
preflight filename (without path) as it reported by Callas.
revision.pdfInfo.pages.XXX.page_height
XXX should be substituted with the page number. Note that pages are numbered from 1, not from 0.
revision.pdfInfo.pages.XXX.page_width
XXX should be substituted with the page number. Note that pages are numbered from 1, not from 0.
revision.pdfInfo.output_intent
 
revision.createdBy.name
Name of the user who initially created the revision (i.e. uploaded the artwork)
revision.createdBy.email
Email of the user who initially created the revision (i.e. uploaded the artwork)
revision.preflightedFile
Name of the preflighted file for this revision (according to the template defined in System Settings)