Applying formatting and styling to agent-generated PDFs with OOTB pyCreateandAttachPDF

I am using a Pega Agent to generate PDF documents. The agent calls the OOTB tool pyCreateandAttachPDF to create the PDF and attach it to the case.

The PDF is created and attached successfully. However, the output is plain, unformatted text, which makes it hard to read and not suitable to share with clients.

What I’m trying to achieve
Professionally formatted PDFs with a consistent structure: headings, subheadings, tables, bullet points, and proper spacing. Ideally the PDF would follow a client-specific template or document style guide covering fonts, colours, margins and layout.

What I’ve tried

Adding formatting and styling instructions to the agent’s instructions (e.g. “use headings, tables and bullet points”)
In every case, the generated PDF still renders as plain text.

Questions

Can an agent be made to follow a predefined PDF style guide (fonts, headings, colours, tables, margins, structure)?
If agent instructions alone aren’t enough, what is the recommended template-based approach?

Any guidance, examples or best practices from anyone who has implemented something similar would be much appreciated.

Thank you.
Arunkumar

Hello Arun,

If you are expecting fancy or professional PDF’s, you have to use EForm templates which contains headings, subheadings, tables, bullet points, and proper spacing ,etc along with all the dynamic fields (blank textboxes) already mapped in the PDF with certain field names configured on it. In Pega you can use external Java API’s like com.lowagie.itext or PDFBox to generate the PDF using Java code in a function with your case ID fields mapped to those PDF fields.

I have only tried these two and there could be more as well. Fortunately, both these packages are shipped as part of Pega Infinity already. You can search in Java classes in Admin studio.

Personally i like PDFBox https://pdfbox.apache.org/ and it works like a charm.

Additionally you can look at this post for some additional information on the same context (Not exactly relevant but will give you an idea)

Hope this helps

Regards

JC

I think the PDF is still generated through Systematic way though it’s triggered from Agentic tool. It uses OOTB pxCreatePDF with the sample section and it’s fills in the data that was part of the Agentic response.