Generating complex PDFs from your UI
Provide your users with tools to import case information to their own devices. By configuring an out-of-the-box activity to convert case data to a PDF file, you help users access and archive information that is related to their cases with less effort and at any time.
For example, in a price comparison application, you can configure a button that prints out a PDF of the offers that the user selects for comparison.The pyViewAsPDF activity is an example of an out-of-the-box solution that you can use to generate a PDF. You can also build a custom activity that matches your business needs and add steps that generate PDF files in the context of that activity. In that scenario, configure the Property-Set-HTML method as described in the following procedure and add a step calling the HTMLToPDF activity.
In the navigation pane of Dev Studio, click Records.
Expand the Technical category and click Activity.
Open the pyViewAsPDF activity.
Define the HTML content from which you want to generate the PDF:
Expand the Property-Set-HTML method.
In the HTMLStream field, enter the name for the HTML fragment on which you want to base the PDF, and then click the Open icon.
In the New tab, click Create and open.
In the HTML Source field, enter the HTML code that you want to use to generate the PDF.
To enable custom fonts in the PDF output, perform the following actions:
Upload the
.ttf
file of the font that you want to use as a binary file.For more information, see Creating binary file rules.In the HTML Source field, add the custom font reference by using the @font-face rule.
Click Save, and then return to the pyViewAsPDF tab.
Define the name for the output PDF file:
Expand the Property-Set method.
In the Param.PDFName row, in the PropertiesValue field, enter the name of the file in double quotation marks.
Click Save.
Creating PDF files by using a compact style sheet
Adjust the style of your PDF to the needs of your business by using a custom compact style sheet (CSS).
When you create a PDF file by using the Create PDF smart shape or the HTMLtoPDF activity, the system automatically applies the application skin CSS to the PDF. To change this default setting, enable CSS processing for PDF files, and upload the target CSS file to Pega Platform.In the header of Dev Studio, click
.On the New tab, define the text file record configuration and context, and then click Create and open.
The file extension for text files containing CSS is .css.In the text field, enter the CSS markup.
You can also upload an existing file by clicking Upload file.In the upper-right corner of the form, click Save.
In Dev Studio, search for UseCompactStylesforPDF dynamic system setting, and then click the result that appears in the dialog box.
On the Settings tab, in the Value field, enter
true
.Click Save.
Creating a text file that holds the custom CSS
Enabling CSS for PDF files
Previous topic Building custom UI capabilities Next topic Creating auto-generated custom controls