Using Templates

The templates referenced in the File Destination Properties use simple tag substitutions. You can use the value of any file metadata property in a template expression by enclosing the property name in braces and preceding it with a dollar sign. This creates a tag such as the one shown here: ${name}

This tag is then replaced with the value of the specified property for the document.

All incoming property values are converted to strings of characters when referenced in a tag. The substr function provides a way to use only a portion of a value string. The substr function and parameters replace the property name in the tag and are written this way:${substr(name, start[,end])}

Parameter Description
name The name of the parameter to substring.
start The zero-based position of the first character to use.
end The optional one-based position of the last character to use. The default is the end of the value.

For example, if an incoming property name is USER_ID and the value is user:John Doe, then the following tag produces the value John Doe: ${substr(USER_ID,5)}

Likewise, this tag becomes John when processed: ${substr(USER_ID,5,9)}

Date (time) values retain their type as a date when carried in parameters. When referenced as a template tag, however, the date is converted to a string. The default format of this conversion is influenced by the locale and date settings on the system running Documaker Connector.

syntax to control the date and time format:${name?string.dateformat[_timeformat]}
Parameter Description
name The name of the date parameter to format
xxxformat Specify one of these options: short, medium, long, full, short_long, or long_short.
short :     4/27/12 12:34 PM 
medium:     Apr 27, 2012 12:34:56 PM 
long:       April 27, 2012 12:34:56 PM EDT 
full:       Friday, April 27, 2012 12:34:56 PM EDT 
short_long: 4/27/12 12:34:56 PM EDT 
long_short: April 27, 2012 12:34 PM

How everything looks exactly is affected by your local system settings. Instead of using the default formats, you can specify the exact format using the Java date format syntax for pattern:${name?string(pattern)}

Here are some examples:
${myDate?string("yyyy-MM-dd HH:mm:ss zzzz")}
           2012-04-27 12:34:56 Eastern Daylight Time
   ${myDate?string("EEE, MMM d, ''yy")} 
     Fri Apr 27, '12
   ${myDate?string("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'")} 
     Friday, April 27, 2012, 12:34 PM (EDT)

Documaker Connector uses an open source library called FreeMarker to provide much of the template functionality. For more information, see the FreeMarker documentation located at this website:https://freemarker.sourceforge.io/docs/ref_builtins_date.html

Keep in mind you can only use the capabilities of the library that are supported by our implementation within Documaker Connector. For example, parameter values are all strings or dates. All other types are converted to strings.