Question about PDFGenerationAPI fillDocumentFieldsAndFlatten method with font
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 12:49 PM
Hi ServiceNow Community,
How do we set the font used when we want to use the method fillDocumentFieldsAndFlatten method from the PDFGenerationAPI? By default, it keeps filling in the PDF with the font Arial. I want to use Times New Roman.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 04:42 PM
@zynsn Font family can be set only via the convertToPDF method of PDFGenerationAPI. Details can be found here https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/P...
There is also a nicely written article which shows how font family can be updated via covertToPDF method.
However, setFontColor and setFontSize methods are available.
setFontColor(Color color): https://developer.servicenow.com/dev.do#!/reference/api/utah/server/sn_pdfgeneratorutils-namespace/S...
setFontSize(Number fontSize): https://developer.servicenow.com/dev.do#!/reference/api/utah/server/sn_pdfgeneratorutils-namespace/S...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 07:40 AM
Hi Sandeep,
Thank you for the information. Would it be possible to use fillDocumentFieldsAndFlatten method and then use the convertToPDF method to set the font?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 08:44 PM
HI @zynsn ,
I trust you are doing great.
Please find below sample code for the same :
// Pseudo-code example
var pdfGen = new PDFGenerationAPI();
var config = {
fontName: 'Times New Roman' // Specify the font here
};
pdfGen.fillDocumentFieldsAndFlatten(template, fields, config);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2023 07:38 AM
Hi Amit,
That doesn't work. It seems like the font cannot be set when using the fillDocumentFieldsAndFlatten method.