Download a Section as PDF on click of a button

I have a section with some fields header footer and a table. I want to download this section as PDF on click of a button.

I am writing an activity on open url window. In the activity I am setting up the markup property using property-set-stream and calling the activity HTMLTOPDF followed by code-pega-pdf.view activity.

The UI is not correct for example borders are missing and in header able to to “Enter to sort” text along with table header text.

I want header and footer to fixed to the page of pdf.

Please guide me to achieve this requirement. I want a perfect solution to get the section as its in pdf.

Thank you.

@AyeshaK4 I notice that you asked the same question as a Discussion here - I have removed that post.

Please only use the ‘Ask a Question’ and do not post duplicate posts.

To generate a PDF from a section in Pega, you can use the OOTB (Out of the Box) activity HTMLToPDF. However, this activity might not perfectly replicate the UI of the section, as it converts the HTML stream to PDF and some styles might not be supported.

For the issue with the borders, you can try to define them directly in the style tag in the stream.

For the “Enter to sort” text appearing in the header, it seems like the grid headers are being included in the PDF. You can try to hide them using CSS in the HTML stream before converting it to PDF.

To have a fixed header and footer on each page of the PDF, you can create HTML rules for the header and footer and set them as parameters for the HTMLToPDF activity.

Please note that achieving a perfect replication of the section in the PDF might require some trial and error and adjustments in the HTML and CSS.

:warning: This is a GenAI-powered tool. All generated answers require validation against the provided references.

Generating and Viewing PDF

Ask the Expert - Pega and PDFs with Rahul Bojanapally and Sangeeta Kottilinga

i want use page numbering in PDF

Setting margins in PDF’s.

on click of BUtton , PDF link should be opened in modal dialogue

Header screen layout issues

Whilst we give time to our forum users to find your question can you please go through the below available resources?

Carry out a PSC search:

Also check the Resolved Issues documentation for ‘PDF’ fixes.

@MarijeSchillern Thank you for your reply,

By adding the CSS code in the html steam. Will this solution work in the production environment also.

Thanks

I am trying to add code in pyCompactStylesforPDF, but it is not working any suggestions.

Thanks

@AyeshaK4 - If directly passing the html rule to Markup then the styles wont be passed. Either pass the link tag in html to refer pyCompactStylesForPDF CSS file as below

or Pass a section using below steps to generate the html content and pass to Markup. This way based upon DSS value of UseCompactStylesForPDF it picks the CSS. If the DSS true its pick from pyCompactStylesForPDF css file and if it is false then skin.

  • Step1 - set param.SectionName to section rule name by using property-set step

  • Ste 2 - set param.HtmlStream to “pzCreatePDFHarnessWrapper” using property-set step

  • Step 3 use Property-Set-HTML to set param.Markup to param.HTMLStream

Thank you.

@AyeshaK4

Hi,

Configure a button in a section and call the OOTB activity pxCreatePDF and pass the required parameters which are Section Name, PDF File Name, Attachment Category. please find the image for your reference.

@Mamatha Adiraju

Thank you