How to set variables in the proof

Concept

A proof 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.

Numbers and strings formatting

Example

%job.props.print_height|.3d%

See PHP sprintf() documentation for full description of possible format strings.

Note the differences:

  • 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.

Date and time formatting

Example

%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 foundhere.

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.description|10:.10s%< 20 characters length ers length Note that the output started from 10th symbol.
>%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.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
  • product_types
  • 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.
job.props.printHeightInches Value of print_height dynamic property converted to inches.
job.formattedFinalSize Contains formatted final size of the job (created from print_width and print_height dynamic properties), in system dimension units. Example:
2.450 x 3.457 in
job.createdBy.name Name of the user who initially created the job
job.createdBy.email Email of the user who initially created the job
job.scale_pages_xjob.scale_pages_y These variables are used for scaling PDFs. The job.scale_pages_x variable yields the smaller of properties print_height and print_width, or, if these properties are empty, the length of the shorterside of the trimbox of the first page in the PDF. Correspondingly, the job.scale_pages_y yields the largerof those properties or the length of the longer side of the trimbox. Both these variables are in inches.

Referencing the order

Name Description / Notes
order.name  
order.description  
order.kfpx preflight filename (without path)
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
  • product_types
  • 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.formattedFinalSizeXXX 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  
revision.pdfInfo.pages.XXX.page_width  
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)

Note that revision.pdfInfo… variables yield values in system default measurement units. To get values in inches or millimeters, use revision.pdfInfoInches… or revision.pdfInfoMm… respectively. For example, revision.pdfInfoMm.pages.1.formattedMediaboxSizeyields string like 10.000 x 20.000 mm even if system default measurement units are inches.