1. Tasks
  2. Generate PDF

Tasks

Generate PDF

This task is used to generate a PDF of a predefined PDF template. The template can be created and edited within the Stubber UI. Custom data can be passed to a PDF template, such that dynamic data can be displayed in each PDF.

The rest of this document assumes familiarity with adding a task to a stub. See [ADD LINK] [tasks documentation]

Basic usage

loading...

Parameters

pdftemplateuuid

required
string

This is the unique identifier for the pdf template to use in the task. It is automatically inserted when a pdf template is selected from the dropdown in the user interface.

Default: null


data

optional
object

The data to be passed to the pdf generation step. All data values in the pdf template will be substituted with these data values. See Examples section.

Default: null


new_file

optional
object

Parameters about the new pdf file that will be generated by the task.


new_file.filename

optional
string

The name that the newly generated pdf file should have. Example PDF {{stub.stubref}}.pdf

Default: null


Result

loading...

Properties

file

The pdf file that was generated by the task.


file.filename

The name of the file that the task generated.


file.originalname

A duplicated of the file name.


file.fileuuid

The unique identifier for the newly generated pdf file on the Stubber system.


file.contentType

The content type of the newly generated pdf file, this will always be application/pdf


Using the User Interface

The user interface is where you will be able to delete, create or copy a PDF Template. It is also where you will select the PDF Template to modify it.

From the Tasks tab when editing an action, click the Edit Task icon to open up the task editor.

ss_generate_pdf_params

The above elements explained:

  1. Field to enter the template name when creating a new template from scratch
  2. Clicking this creates a new PDF Template with the name entered in (1) above. Once you have created a new template, you will need to refresh the page for it to appear in the Select PDF Template field (3)
  3. A select box to select a template you wish to duplicate, delete or edit.
  4. The template duplicate button. This will make a copy of the Template selected in (3) above, using the name entered in (1) above. Refresh the page for the new template to appear in the Select PDF Template field (3)
  5. The template delete button. This will delete the Template selected in (3) above. Be aware, no warning will be given, the template is removed upon clicking this button
  6. The edit template button. This will open the template for you to edit it within the Stubber page.
  7. Field to assign a filename to the pdf file that will be generated. You can use Inline Text Substitution when defining the filename. Don't forget to give the .pdf file extension.

The PDF Editor

When you edit a PDF Template, you will be presented with the screen as shown below. This is where you can use all the elements provided to build the contents and layout of your PDF.

ss_generate_pdf_editor

WARNING

Remember to save your template regularly and before closing this editor window.

Examples

Here are some more examples, with screenshots of the resultant pdf files.

The basic usage with the result

This is the basic usage example, with a screenshot of the generated pdf at the bottom.

loading...
Result
loading...

basic-usage-generated-pdf


Generate a quote

Generate a quote, dynamically add in customer details and the line items of the quote via the data parameter, use jsonata to calculate totals.

The task definition:

loading...

The data:

loading...
Result
loading...

The generated pdf file: generate-quote-pdf