Create Preview PDF

The Create Preview PDF plugin generates a PDF preview for a single record as fast as possible. This preview is typically used for previews embedded in web pages.

The plugin retrieves the resulting PDF from the file store and makes it available to the process as the job data file. The job file name extension is .pdf.
This file could be written to a publicly accessible location (for example the _iRes folder) so that the path could be served back to the browser, allowing the web page to embed the PDF data for online viewing.

To make the rendering process as fast as possible, the generated PDF isn't optimized for print production purposes.

Content creation may be aborted by a script in a Connect template that raises a fatal error. This triggers the On Error tab of the Content Creation task. See Designer Script API.

Properties

Datamapper tab

The Create Preview PDF plugin gets one record from the source selected on the Datamapper tab. This record is then merged with the template (selected on the Content Creation tab) to create a preview PDF.

The Datamapper tab can have one of the following source options:

  • Data mapping configuration sets the data source to a data mapping configuration.
    • %o: Select this to use a dynamic data mapping configuration name. Click on %o to change the expression that determines the name of the data mapping configuration to use.
    • Alternatively, select a configuration name. Adding configurations to this list is done through the Send to Workflow option in the Designer module.
      Click the Open data model of selected configuration button to view the data model attached to the chosen configuration in the DataMapper module, to verify that the right one is used.
    • No storing or post-processing of the data records (faster): This option prevents data from being written to the database. Instead, records are streamed directly into the Content Creation process for immediate merging. Turning this feature on can improve data mapping performance significantly, as well as the time required for the cleanup process. However, since the data is not written to the database, there is no way to do post-processing on the extracted data. Any post-processors defined in the data mapping configuration will be disabled.
      This option is unchecked by default.
    • When the data mapping configuration provides multiple records, the preview is created based on the first record.
    The Create Preview PDF plugin cannot parse Workflow automation variables. Instead it uses the default values set up in the Preprocessor of the data mapping configuration.

    To work around this issue you could either convert the posted data file into JSON, add the variables and use the JSON string option in the Create Preview PDF plugin, or you could add the variables to the data file and let the data mapping configuration extract them.
    Another alternative would be to use the All In One task.
  • JSON string sets the data source to a JSON string (see Using JSON). A text area is shown allowing the user to enter the JSON string.
    The JSON string may contain local and global variables, Job Infos and data selections (see JSON string samples).
    A single variable can be used, assuming that the respective variable contains a JSON string.
    In case the JSON string is not a valid JSON object, the plugin will error out with an explicit message.
    This option requires that keys in the JSON string have matching field names in the data model of the template. When they have, the JSON values are passed to the template and the personalization scripts of the template will have access to the values through the record's data fields. (See the Designer help: Adding Variable Data).
  • Metadata uses existing metadata, generally the output of a Create Record Set or a Retrieve Items task set to retrieve a record.
    Update fields with metadata: when this option is selected, the plugin will update fields in the Connect database based on the metadata content. This is only useful if the Workflow process has modified the metadata and the corresponding fields should be updated in the database before creating the preview PDF.
    The Metadata option requires that entries in the metadata have matching field names in the data model of the template. When they have, the values are passed to the template and the personalization scripts of the template will have access to the values through the record's data fields. (See the Designer help: Adding Variable Data).
Using JSON

In web environments, it is common to send and retrieve data from a server using an AJAX request (typically invoked from within a JavaScript). Then the data is often exchanged in JSON format. JSON is short for JavaScript Object Notation. It is a way to store information in a structured and easy to read format. It is often referred to as XML without nodes and meant for exchanging data.

Refer to the following online resources for more information on JSON:

JSON string samples

The following JSON string samples show various techniques to incorporate data in a JSON string.

A simple JSON structure holding the first and last name of a person:

{
"first": "Peter",
"last": "Parker"
}

A JSON string with references to local variables and Job Info 2:

{
"first":"%{first}", 
"last":"%{last}", "email":"%2" }

A JSON string containing a local variable and various lookups:

{
"jobid":"%{jobid}",
"account":"lookup(OLCS_jobs, account, jobid, '%{jobid}')",
"datafile_name":"lookup(OLCS_jobs, datafile_name, jobid, '%{jobid}')",
"pages":"lookup(OLCS_jobs, pages, jobid, '%{jobid}')",
"documents":"lookup(OLCS_jobs, documents, jobid, '%{jobid}')",
"recordsetid":"lookup(OLCS_jobs, recordsetid, jobid, '%{jobid}')"
}

An example where the entire JSON string is provided in Job Info 1:

%1

A JSON string constructed with information retrieved from an XML job data file:

{
"first":"xmlget('/request[1]/values[1]/first[1]',Value,KeepCase,NoTrim)",
"last":"xmlget('/request[1]/values[1]/last[1]',Value,KeepCase,NoTrim)",
"email":"xmlget('/request[1]/values[1]/email[1]',Value,KeepCase,NoTrim)" }

A JSON string that contains nested data:

{
"name":"Peter Parker",
"email":"parkerp@localhostcom",
"ExtraData":"foobar",
"detail": [{"id":"inv123","ExtraData":"hello"},{"id":"456","ExtraData":"world"}]
}
Content Creation tab

The Create Preview PDF plugin creates a preview PDF from a template selected on the Content Creation tab, using the record that results from the data source selected on the Datamapper tab. The record is then merged with the template to create a preview PDF.

Select the appropriate template or option:

  • %o: Select to use a dynamic template name. Click on %o to change the expression that determines the name of the template to use.
  • A template name: Select the appropriate template name from the list. Adding templates to this list is done from the Send to Workflow option in the Designer module.
    A preview will be displayed of the output generated by the Print context of the selected template. (Not available for a dynamic template name).
OL Connect Proxy Tab
  • Server Connect Settings
    • Connect Proxy Address: Enter the machine name or IP Address where the OL Connect Server resides.
    • Port: Enter the port to use to communicate with the OL Connect Server. Default: 9340.
    • User name: Enter the user name expected by the OL Connect Server.
    • Password: Enter the password expected by the OL Connect Server for the above user name.
On Error Tab

For a description of the options on the On Error tab see Using the On Error tab.

Miscellaneous Tab

The Miscellaneous tab is common to all tasks.

It contains a text area (Task comments) that lets you write comments about the task. These comments are saved when the dialog is closed with the OK button and are displayed in the Task Comments Pane.

Check the option Use as step description to display the text next to the icon of the plugin in the Process area.

The tab also provides an option to highlight the task in The Process area with the default color, set in the Preferences (see General appearance preferences), or the color selected or defined under Highlight color on this tab.
To revert the selected highlight color to the default color, open this tab, turn the Highlight option off and close the dialog with the OK button; then turn highlighting back on.
Highlighting can also be turned on and off via the task's contextual menu and with the Highlight button on the View ribbon.