Print Rich Text Editor Field as PDF/WORD

Hello everyone, i have a requirement to print the content of the Rich text Editor field as a PDF , i tried using the HTMLToPDF activity and others that i found on the pega baseclass and Work- class.

But without success.

I’m setting a template on the pre process of the flow action in the rich text editor field, and i need to print it after some changes on the field by clicking on a button on the same screen and printing the content of the RIch text editor as a PDF.

Does anyone know a way of doing it?

@GustavoBezerraNeto

Generating a PDF always takes a section as a template, even in Constellation architecture.

PFB the article related to generating a PDF using a Section as a wrapper-

This approach holds valid for Theme-Cosmos based app as well.

I would suggest you to create a wrapper section which refers to the RTE.

Also, You can use the OOTB ‘Print’ action which needs a Harness named ‘PrintView’ and in that harness you can refer the wrapper section above which refers to the RTE.

Also it entirely depends on the intention of Generating a PDF- if you want to attach the generated PDF on a case, the approach changes to running an activity on a click of a button and perform a AttachContent using the generated PDF steram.

Let me know your thoughts on the implementation and requirement if this doesnt solve your query

@RaviChandraThanks for the explanation,

Do you have any example about how to reference the RTE on the section? Either on the HTML source or in another way on a section?

Basically, the RTE will suffer some changes on the doc, so after this changes, the user will press a button to download the file/ pre visualize it.

Thanks in advance.

@GustavoBezerraNeto

  • Create a section that has RTE as an item and refer to the Clipboard property where your changes made in the RTE will be saved.
  • Include This Section in a Non-Auto Generated HTML Section. Use below syntax-

<pega:include name=“YourRichTextSectionName” />

  • Use HTMLToPDF Activity to Convert to PDF

HTMLStream --> The HTML content to convert (his Section in a Non-Auto Generated HTML Section).

PDFDocument --> Name of the output PDF file.

pyOutputType --> Set to "PDF".

Let me know if there you need any additional information

@RaviChandra
I tried your solution, but PEGA doesnt find the section even to save making the reference directly. The section need to be in the work layer because it will be used for all cases.

If you have any input, i appreciate, gonna try to find a workaround.

Thanks again