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.
Basic usage
Parameters
required string
pdftemplateuuid 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
optional object
data 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
optional object
new_file Parameters about the new pdf file that will be generated by the task.
optional string
new_file.filename The name that the newly generated pdf file should have. Example PDF {{stub.stubref}}.pdf
Default: null
Result
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.
The above elements explained:
- Field to enter the template name when creating a new template from scratch
- 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) - A select box to select a template you wish to duplicate, delete or edit.
- 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) - 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
- The edit template button. This will open the template for you to edit it within the Stubber page.
- 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.
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.
Result
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:
The data:
Result
The generated pdf file: