Generated PDF using PDF generation API has margin issue, JPG image seems to be causing it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 04:32 PM - edited 04-14-2025 04:34 PM
I am troubleshooting a case where the generated pdf has margin issue, the content is truncated or cut from the right side. Upon testing same data used, when one image is removed or not included the PDF is generated correctly.
Maybe you have experienced this kind of issue or if you have any idea if an image can cause such error and how to prevent it. thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:09 PM
can you share your code which generates that PDF?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 08:38 PM - edited 04-14-2025 08:40 PM
Sure, just to give you a brief context, there's a record producer for creating a kb article and once created that kb article will be published along with the PDF version attached to it. The images inserted in the html field in the record producer will also be in the PDF file.
here's the part where the PDF generation API is called in the business rule triggered when kb is created.
this is where the header of the pdf processed.
then this is a snippet where the data html data is formed from the record producer.
and then here's where the PDF is created and attached to the kb and also the function to handle the attachment/image for the header:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 09:55 PM
I believe some limitations might be there.
But please check this link
San Diego: PDFGenerationAPI No Longer Respects CSS Paged Media
OR
Another way is to use HTML document templates and generate PDF using that, try that
Document Templates auto-generate a PDF and attach to case
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 05:40 PM
thanks, the system property update did not work and we also cannot use a template as there are existing format they want that we are currently using.