Seeking Expert Guidance for Advanced HTML to PDF Conversion in ServiceNow

MA16
Tera Expert

Greetings ServiceNow Community,

I'm currently tackling a complex project involving the conversion of HTML content to PDF within the ServiceNow platform. While I've made progress with basic HTML to PDF conversion, I'm now facing more intricate challenges that require expert insights.

Firstly, I need to dynamically create HTML content with user-specific data and smoothly convert it to PDF within ServiceNow. I'm struggling to maintain consistent styling and formatting across both the HTML content and the resulting PDF document, especially with complex layouts and CSS.

Additionally, I'm encountering difficulties when handling large documents. Converting extensive HTML content, spanning multiple pages, to PDF in ServiceNow without performance issues or memory constraints is proving to be a tough nut to crack.

I'm also looking for ways to include interactive elements in the PDF. Is it feasible to embed hyperlinks, form fields, or JavaScript-based interactions in the HTML content and retain them in the generated PDF?

Furthermore, I'm interested in learning how to add custom header and footer sections to the PDF document, including dynamic content such as page numbers or document titles.

3 REPLIES 3

JohnnySnow
Kilo Sage

Hi @MA16 , have you tried exploring PDFGenerationAPI?

Thanks
Johnny

Please mark this response as correct or helpful if it assisted you with your question.

Ionut Carp
Giga Sage

Hi,

 

You can use Document Templates plugin (is free) which you will help you to configure HTML or fillable PDF. After that you can use PDFGenerationAPI to generate the pdfs based on the templates set using the plugin.

 

You can find more in the links below:

https://www.servicenow.com/community/developer-articles/fill-fields-and-adding-an-image-signature-in...

 

https://docs.servicenow.com/bundle/washingtondc-employee-service-management/page/product/human-resou...

 

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/app-store/dev_portal/API_referenc...

 

Let me know if this helped you.

 

Ionut

SwarnadeepNandy
Mega Sage

Hi @MA16 ,

 

I'm facing a similar challenge where I need to generate PDFs with specific branding and formatting, including rotated text. I've found that ServiceNow's built-in PDF generator doesn't fully support some CSS features like @media queries and @page rules, which can limit design flexibility.

It seems we're on the same track with exploring JavaScript libraries for HTML to PDF conversion. I'm currently looking into options like jsPDF and html2pdf.js. They seem promising for achieving the level of customization we need.

Have you made any progress with your solution? I'd be interested in hearing about your experience and any libraries you've found to be effective. I'll also share any findings I have as I continue to explore this.


Kind Regards,

Swarnadeep Nandy