Posted: 23 Apr 2019 13:17 EDT Last activity: 2 Jan 2020 15:59 EST
HTML to PDF generation
If anyone has tried to do HTML to PDF generation using the Pega OOTB smart shape functionality, you know that it, uhhhhh, leaves a lot to be desired. It actually produces some pretty horrible looking PDFs. For our needs, we have very well designed and professional looking PDF's that need to be generated from HTML and then sent to a number of different external stakeholders.
We know we don't like the PD4ML solution that's under the covers in the Pega OOTB and it doesn't meet our needs.
We would like to avoid re-writing our solution using eForms and the other cons that come with that solution.
What other solutions have others used?
We are considering using wkhtmltopdf (https://wkhtmltopdf.org/) because it produces great looking PDFs in the format and with the look/feel we need. However, it is a command line based tool and does have a Java Wrapper, but under the covers its still a command line based tool. We are thinking we would need PegaCloud team to install that command-line tool on the server for us. And, well, that can get a little dicey. :) Has anyone used wkhtmltopdf in Pega?
If not, I ask again, what other solutions have others used?
***Edited by Moderator: Pallavi to update platform capability tags***
Hey Chandra. Thanks for your response. I've seen and read those posts. I don't think there is a post on the community about HTMLtoPDF that I haven't read. Ha! :)
The problem isn't generating a PDF from HTML. We can do that very easily. This issue we have is that the resulting PDF from the Pega OOTB HTMLtoPDF activity is absolutely horrendous looking. :) It loses all formatting and styling and layouts that are applied in the HTML and it does not look like a nicely formatted and spaced professional document.
We are looking for a solution that doesn't require us to hand-code HTML snippets nor require us to use eForms. There are a lot of products on the market that covert HTML to PDF and retain all look/feel and styling of the HTML in the PDF.
The one we like the most is wkhtmltopdf, however it is a command line tool. It does come with a Java wrapper that we can call from a Pega Java Function, however we need the wkhtmltopdf command line utility installed on the server (Pega Cloud) for this to function properly.
My question is: Has anyone ever used wkhtmltopdf in Pega, if so, how? If not, what other easy to use and maintain solutions have others leveraged to generate great looking HTML to a great looking PDF?
Pega has provided one css file for pdf "pyCompactStylesForPDF" which has minimal styles ,you have to include that in your HTML stream where you are including the section in HTML Stream. Then it picks most of the styles but we need to make changes according to our requirement which you have to do by overriding the css.
Thanks to those that responded. We ended up creating the HTML using paragraph rules and using a CSS to style them before calling the pdf activity. Worked fine. Not as we wanted, but we have PDF's that look good now.
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.
I am facing some issues with alignment (for checkbox and radio buttons, text/label is coming down for checkbox and vice versa for radio buttons ) while generating pdf, almost followed the same steps mentioned above. is there anything else i need to take care of? please share.
Thank you for posting your query on PSC. This looks like an inactive post and hence, we suggest you create a new post for your query. Click on the Write a Post button that’s at the top of this screen and also on our Pega Support Community homepage. Once created, please reply back here with the URL of the new post.
We have also sent you a private message opening up a communication channel in case you have any further questions.