Support Article

Section formatting not preserved when converting to PDF



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

  1. Create a section containing three columns (for example, an inline grid triple) and provide each column some content.
  2. Create an HTML (JSP) object.
  3. Include the section (created in Step 1) in the HTML.
  4. 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.


Perform the following local-change:
  1. 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" />

  2. Create an activity to construct the PDF.
  3. 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

  4. In the first step of the activity, perform a Property-Set. These values are used later.


  5. In the next step of the activity, call Property-Set-HTML​​​.

    properyName = param.Markup
    HTMLStream =  "pzCreatePDFHarnessWrapper"

  6. Call Property-Set-Stream. 

    PropertyName = Param.MarkupStyles 
    StreamClass = Rule-HTML-Fragment
    StreamName = HTML fragment name created earlier

  7. 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 -->"; 
                  tools.putParamValue("Markup", ,Markup);

  8. Call HTMLToPDF.

  9. 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.

  10. 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.
  11. In this case flow, add a Utility smart shape.

    Rule = <name of the activity created above>.

  12. ​​​​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.