The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to generate a custom pdf for a report in Servicenow

Debolina
Tera Contributor

Hi All,

 

I have a report for the project table and now I want to extract a pdf from that report. The oob pdf is fine but client needs some changes on the field width and colors. I believe we cannot do those modifications on the oob template, so is there a way to generate a PDF for a report using Document Template?

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Debolina 

yes you can use your custom document template and generate and attach the PDF to the project record

you can check the PDF Generation API for this

Generating Custom PDFs - using the new PDFGenerationAPI

Also you can configure the document template and refer my blog on script to generate and attach the PDF

Generating and Attaching Document Templates in ServiceNow to Record - Server Side 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

M Iftikhar
Mega Sage

Hi @Debolina

 

The recommended best practice for creating customized PDF with specific styling (colors, field widths, logos) is to create a UI Page or a Service Portal widget. This approach allows you to:

  1. Use a script to fetch the same data that your report uses.

  2. Render the data using standard HTML and CSS, giving you complete control over the layout and styling.

  3. Include a button or link that uses a PDF generation library (either client-side like jsPDF or server-side APIs) to convert the styled HTML page into a downloadable PDF.

This method provides the flexibility you need while keeping the solution within the ServiceNow platform.

 

Hope this helps!

 

Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@Debolina 

See if you can edit the OOTB Document template configured on project table.

if you can then map it with the fields you want

AnkurBawiskar_0-1758536934239.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader