Question
TD
CA
Last activity: 17 Nov 2020 11:52 EST
How to generate pdf that has dynamic content like repeating grid that may have 1 or upto 100 records?
Hi,
I have a requirements to generate a pdf preview in external window for the user when clicks on a preview button. This pdf contains repeating grid that may contain 1 or upto 100 records or even more no limits. After the preview user will click on Submit to finalize that pdf.
My first question is what will be the best approach to use to create a pdf? Due to the dynamic in nature pdf may contain the multiple pages.
I will have to save the pdf data into a table so that i can run a nightly job to recreate pdfs from the day and get them copied into a folder.
Please help!
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
TD
CA
Hi Everyone,
Can you please suggest an approach here? waiting for your responses.
Pegasystems Inc.
AU
Hi Abhishek,
1. For launching a preview screen - You can use launch a harness and Target as new Document. Inside the harness you can include a section with Grid. With a button to download the pdf,
2. For creating PDF - you can use HtmltoPDF or pxCreatePDF activities and pass the section name.
and yes, PDF may contain multiple pages, As its depends on the page size, say for example the default pagesize is A4, so the pdf4ml API will resize the content and split between multiple pages if the content exceeds the page size.
For second question, it looks like you want to create a scheduler which would run every day to create a pdf file and save to a folder. Please check the documentation on this particular topic how to implement it.
TD
CA
Thanks Karma1 for your response.
For creating PDF i searched further that using HTMLtoPDF cause styling problems. I this forum i found someone suggested below approach: Can you please help me how can i implement below approach?
Pega version is Pega Infinity 8.2.1.
For the PDF's, we created Paragraph rules that included HTML Rules that represented all the parts of our PDF's (pdf header, pdf body, pdf footer). These Paragraph and HTML rules contain all static content, dynamic content, the paragraph styling, and CSS that we needed. Then in our Generate PDF flow, we called an activity that basically concatenated all of this together in an HTML Stream. In this same activity, we then called pega's OOTB HTMLtoPDF activity passing in the parameter page that contains the HTML Steam. Once the PDF is generated, we then call Code-Pega-PDF.AttachToWork to attach it to the case.
source: https://collaborate.pega.com/question/html-pdf-generation
Pegasystems Inc.
AU
Hi Abhishek,
- You can personalize the styles while generating a pdf through HTMLtoPDF activity by modifying pyCompactStyles.css for pdf, This CSS will be included in Runtime while PDF is being created. Any specific CSS or design changes specific to PDF can be embedded here.
To enable above style sheet you need to enable UseCompactStylesForPDF DSS setting to True.
- From the comment which you have quoted, I believe they have included three different paragraph rules header,footer and body inside a single HTML stream, and finally passed that HTML stream to HTMLToPDF activity.
- The styles related to header,footer and body they have have included in the paragraph rules itself, Since in paragraph rule user has option to include css styles from View Source.
- You can make use of <pega:include> tags to include multiple paragraph rule in a single html fragment. Please google it with above tag, you will get the examples as well.
As per your query, i think you can go for pyCompactStyles.css and customize the styles for table as you want. This will avoid the need to create multiple paragraph rules.
If you find my suggestion is helpful or correct, please mark it accordingly so that it will be highlighted and help others to find the solution easily.
-
Abhishek gupta
Updated: 3 Sep 2020 14:55 EDT
TD
CA
Thank you so much Karma1. I really found this helpful. I am now starting to work on the steps you mentioned. I will come back here if I face any challenges (which i think for sure :P) . But this is a great start for someone who need to create a dynamic pdfs in Pega.
Updated: 14 Sep 2020 11:32 EDT
TD
CA
Hi Karma1,
Your solution was perfect. Was able to built an Paragraph rules. Brushed up my HTML skills to add table in the paragraph for dynamic repeating grid.
After successful implementation i have got another requirements for allowing the user the update the static content on the paragraph. That way technology dont have to involve to make any static changes. Once the user update the static content from the portal system should always pick the updated paragraph to create a pdf.
I am thinking if is there is anyway we can store the enrite HTML of Paragraph in column of a database table? That way if user make any updates the updated HTML will get added to table as a new record. That was system can refer both the old record as well as new record as per the requirements. Because system needs to refer both the old version paragraphs as well as new version paragraphs.
Can you please provide your thoughts?
ProCom Consulting
US
Hello Abhishek,
Can you please let me know, how did you achieve this? Can you share the HTML syntax/code that was used to achieve this?
"add the table in the paragraph for the dynamic repeating grid."
Thanks.