Abstract
In this article, you will learn how to generate PDFs in your Simplifier applications.
Prerequisites
- A customized PDF Template (see Create a PDF Template via Plugin)
Step 1 – Integration into your Application
To generate a PDF in your application, go to the Process Designer, and add a Business Object shape into the Story map where the PDF should be generated.
Select the Business Object “SF_PDF” and select the call “generate”. This business object is part of the Simplifier Standard Content and should already be available.
If you’re missing the Business Object, please visit our marketplace and download the latest version of the StandardContent.
Step 2 – Configurations for the PDF
The Server-Side Business Object ‘SF_PDF‘ has two functions: ‘generate‘ and ‘generateWithConfig‘.
If you simply want to show your data on a PDF, using the function ‘generate’ will be sufficient. However, if you want to add some configurations, like the page size or page orientation, use ‘generateWithConfig’.
‘GenerateWithConfig’ has an additional parameter: ‘configJSON’. In this parameter, you can set your configurations in JSON format.
Example:
var oConfig = { "orientation": "Landscape", "page-size": "A4", "margin-top": "1in", "margin-bottom": "1in", "margin-left": "1in", "margin-right": "1in", "footer-center": "[page] / [toPage]" };
Example Application
Download the example application from the Simplifier marketplace and import the file into your Simplifier instance.
After importing the application and openening it, you should be greeted by a screen displaying a table with some dummy data on the left side and an empty PDF viewer on the right side.
Pressing the Generate PDF Button will generate and display a PDF. Please make sure that the TestTemplate is available on your Simplifier instance.
In case, you want to test the running example with your own PDF template, you just have to replace the PDF template name in the SF_Example_PDF application.
Go to the process designer and open the story “Generate PDF” and change the constant value of templateName in the input mapping of the Business Object “SF_PDF-> generate” which is currently set to TestTemplate.
The data send to the the PDF Plugin is a global variable with a pre-defined value. You can find it on the data workbench.