Support Article
Section formatting not preserved when converting to PDF
Summary
On including a section to an HTML rule, the section content displays without the formatting.
For example,
A section contains three columns with content in each column. On including the section in the HTML rule, the content displays in a single column.
Error Messages
Not Applicable
Steps to Reproduce
- Create a section containing three columns (for example, an inline grid triple) and provide each column some content.
- Create an HTML (JSP) object.
- Include the section (created in Step 1) in the HTML.
- Preview the HTML. The content displays in a single column.
Root Cause
In the Pega platform prior to Pega 7.3, the CSS of the section must be included separately.
Resolution
Perform the following local-change:
- Identify the section that must be included in the HTML. Create an HTML fragment (JSP) to include the .css file.
Below is an HTML source example.
<pega:static type="style" app="webwb">
<pega:file name="<YOUR_CSS_FILE.css" />
</pega:static> - Create an activity to construct the PDF.
- In the Parameters tab, include the following:
Name: SectionName
Data type: String
Required: Yes
In/Out: In
Name: PDFName
Data type: String
Required: No
In/Out: In
Name: UseCompactStylesforPDF
Data type: String
Required: No
In/Out: In
Default value: True
- In the first step of the activity, perform a Property-Set. These values are used later.
set Param.PDFName = "<DESIRED NAME FOR THE CREATED PDF FILE>"
- In the next step of the activity, call Property-Set-HTML.
properyName = param.Markup
HTMLStream = "pzCreatePDFHarnessWrapper"
- Call Property-Set-Stream.
PropertyName = Param.MarkupStyles
StreamClass = Rule-HTML-Fragment
StreamName = HTML fragment name created earlier - For the next step, create a Java step with the following code:
String Markup=tools.getParamValue("Markup");
String styles=tools.getParamValue("MarkupStyles");
String stylePlaceHolder = "<!--Styles for runtime editing -->";
Markup=markup.replaceFirst(stylePlaceHolder,styles);
tools.putParamValue("Markup", ,Markup);
- Call HTMLToPDF.
- Select 'Pass current parameter page' to automatically pass the Markup and StreamName as parameters. This downloads the PDF created to the browser such that it can be viewed. For the final activity step, call Code-Pega-PDF.view. This downloads the created PDF to the browser for viewing.
- Select 'Pass current parameter page' to use the PDFDocument parameter created in the previous step as well as the PDF name set in the first step of this activity.
- In this case flow, add a Utility smart shape.
Rule = <name of the activity created above>.
- Save the changes and run the case to test. Any formatting changes to be made must be performed in the .css file.
Published January 22, 2019 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.