Skip to main content
Version: 2023 R3

Generate a PDF file

The action allows you to generate .pdf files based on templates (in the form of an .html file) previously created by a user.

The action configuration window has three tabs: Template, Appearance, and Output.

Template

A template can include dynamic variables changed into standard or special values.

The section on the Generate an HTML printout action presents examples of printouts for Item lists and Data tables.

To use this functionality, create a file template and then configure relevant actions in a given step in the required workflow. An additional functionality is the ability to save such files directly as attachments to a workflow instance.

Generate a pdf file

1. Template mode

The field allows you to indicate a place from which the template will be downloaded. Three options are available here:

  • From URL – any link allowing to download a document with anonymous access, e.g. http://intranet/workflow/documents/template.html,
  • From attachment – an existing attachment is selected as a template in which changes are made,
  • From document templates process – a template is specified by means of an ID of a document located in the document template process. An ID is a value in the following format: /DOCTEMP/GUID/filename where:
    • DOCTEMP – a fixed name specifying document templates process,
    • GUID – a template ID from an ID field available in the process form,
    • filename – an optional file name.

2. Category

The field is active if From attachment is selected in the Template mode section. It allows you to specify the category of selected files:

  • All – all files attached to the workflow instance are selected,
  • Dynamic – the category can be created dynamically (using Variables editor) or typed in manually. The category should have the following format: ID#Name or ID,
  • None – files not assigned to any category are selected.

3. Convert

The field allows you to specify which attachments are to be converted to the .pdf format. These can be all attachments, only the oldest attachment or only the newest attachment.

4. Regular expression

Search for files to convert based on a regular expression. When creating such an expression, you can use the Creator tool run with a separate button available below this field.

To select right attachments, the regular expression usually needs to follow one of the general formulas presented below:
File1 or File2, example: (criterion1|criterion2)
File1 and not File2, example: ^(criterion1|(?!criterion2))

Examples
  • Simple selection of files only with a specific extension, e.g. “.pdf”:
    .pdf
    Correct expression: Attachment1_File.pdf
    Incorrect expression: Attachment1_File.docx

  • All .docx and .pdf files. The extension is checked and the name is skipped:
    ^.*(docx|DOCX|pdf|PDF)$
    Correct expression: Attachment1_FileName007.docx
    Incorrect expression: Attachment1_FileName007.txt

  • The file name starts with a clearly defined word (here: WEBCON) followed by the __ or - symbol, any number of alphanumeric characters, and ends with .docx or .pdf extension:
    WEBCON(_|-)[a-zA-Z0-9]*\.(docx|pdf)$
    Correct expressions: WEBCON_FileName007.docx; WEBCON-FileName007.pdf
    Incorrect expressions: WEBCON FileName with spaces.pdf; SharePoint_FileName123.pdf

  • The file name starts with a date with the following format: “YYYY-MM-DD”, followed by the __ or - symbol, any number of alphanumeric characters, and ends with .docx or .pdf extension:
    ^\d{4}\-(0?[1-9]|1[012])\-(0?[1-9]|[12][0-9]|3[01])(_|-).*\.(docx|pdf)$
    Correct expressions: 2015-07-09_FileName007.docx; 2015-07-09-File123_New.pdf
    Incorrect expressions: 2015/07/09-NotGonnaWork.docx; WEBCON_2015-07-09_File.pdf

  • The words in the file name are separated with the - symbol and end with .docx or .pdf extension:
    ^[a-zA-Z0-9]+(?:-[A-Za-z0-9]+)*\.(docx|pdf)$
    Correct expressions: WEBCON-File-New.pdf
    Incorrect expressions: WEBCON_File_Old.docx

5. SQL query

The field allows for specifying source files based on an SQL query. The query should return a list of attachment IDs from the "WFDataAttachmets" table.
If a query returns more than one ID, only the first-on-the-list attachment is processed.

Example
Select [ATT_ID] from [WFDataAttachmets] where [ATT_Name] = 'file.html';

6. Template file encoding

Select the encoding system in which the template file is saved.

7. Document template

The section becomes active after selecting the From document templates process option in the Template mode field. Two options are available here:

  • Template source – requires a user to specify a data source and the required template,
  • Dynamically calculated – requires the use of a document ID with the following format: /DOCTEMP/GUID/filename.
Example

/DOCTEMP/ec3b6447-417c-4250-ba7b-0534fdacdd2c/template.html
/DOCTEMP/ec3b6447-417c-4250-ba7b-0534fdacdd2c
ec3b6447-417c-4250-ba7b-0534fdacdd2c#template.html
ec3b6447-417c-4250-ba7b-0534fdacdd2c

8. Variables editor

Dynamically generated tree containing all variables that may be used in the current location of Designer Studio. Information on how to use variables in WEBCON BPS, as well as a list of variables can be found in the dedicated section.

Appearance

The tab allows you to set the appearance of the resulting .pdf file.

Appearance

1. Allow splitting images between pages

Checking this option allows the system to split an image between pages if it does not fit one page due to its size or location.

2. Show header

Define a header using the CSS and HTML languages. When checked, the fields Height and HTML become active.

3. Margin settings

Ability to set custom margins of the generated PDF file.

Define a footer using the CSS and HTML languages. When checked, the fields Height and HTML become active.

The checkbox allows you to enable automatic numbering of pages.

Output

The tab allows you to configure the basic parameters of the resulting .pdf file.

Output

1. Display on screen

If a document is not transferred to the attachment, this option is required and results in showing a dialog window that allows for previewing a document or saving it on the disk.
For documents added as an attachment this option allows you to preview the added attachment.

2. PDF/A file

Ability to decide whether the document will be generated in a special PDF/A format.
This format allows the digital content of a file to be graphically represented in the same way, regardless of the operating system and software used. It is also intended for long-term storage of documents for archival purposes.

3. Add as attachment

The checkbox is used to determine whether the generated document is to be added as an attachment.

3. Category

A category to which an attachment is added. After selecting the Dynamic option, a category with a specified name is created at the first execution of an action.

info

For example use of the action, see the article Certificate generation on our technical blog.