I want to generate a PDF using Section or Paragraph rules and on click of a button, I need to
download the PDF
Configure an activity that again calls two OOTB activities: HTMLToPDF of @baseclass, View of Code-
Pega-PDF class.
I have configured GenerateApplicationForm Activity.
Steps Tab:
Pages and classes Tab:
Dhanalakshmi M
Let’s go through the steps.
In Step 1,2, and 3, I am setting Header, Footer and Markup parameter values by passing the
StreamClass as Rule-HTML-Section and the StreamName as the section rule name to the Property-
Set-Stream method. The PropertyName is the value returned from the method.
If you want to use Paragraph rules, pass the StreamClass as Rule-HTML-Paragraph
Ignore 4,5,6 steps. I have previously created HTML rules. HTML rules are deprecated. So, I have used
Section Rules.
In step 7, I am setting few more parameters before calling HTMLToPDF activity. Setting the
pyPDFHeaderHTMLTemplate and pyPDFFooterHTMLTemplate includes the Header and Footer for the
PDF pages.
Dhanalakshmi M
The HTMLtoPDF activity that you use to generate PDFs from your application supports a number of
parameters for controlling the look and format of your file.
For more such parameters, refer pyPDFSettings Data Transform of @baseclass. You can set these
parameters in your activity before the step of Call HTMLToPDF activity. If not set here, pyPDFSettings
data transform sets the default parameter values needed to render PDF. You can also refer the Pega
Documentation to know the usage of each parameters
https://docs.pega.com/bundle/platform/page/platform/user-experience/pdf-parameters.html
In step 8, I am calling the HTMLToPDF activity. I am checking the Pass Current Parameter Page
checkbox. This activity outputs the PDFDocument parameter which should be passed to activity View
of Code-Pega-PDF class in Step 10.
In step 9, I am setting the PDFName.
In step 10, I am calling the activity View. First provide the step Page as PDFPage (as defined in Pages
and Classes Tab), then select Call method and enter the activity name View. Check the Pass Current
Parameter Page check box.
Dhanalakshmi M
Now, in the UI section, I am configuring the button as below. I have implemented the download
functionality using Open URL in Window. I don’t want to show the download window as a pop up.
So, I am setting the Window name as “_self”
If you want to attach the PDF to the case, you can use OOTB activity AttachToWork of Code-Pega-PDF
class. You need to pass the InsHandle (pzInsKey of the Case), PDFName, PDFDocument (Output
parameter of HTMLToPDF activity).
Dhanalakshmi M