Question about PDFGenerationAPI fillDocumentFieldsAndFlatten method with font

zynsn
Tera Expert

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.

 

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@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.

https://www.servicenow.com/community/developer-articles/generating-custom-pdfs-using-the-new-pdfgene...

 

However, setFontColor and setFontSize methods are available.

SN_PDFGENERATORUTILS


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...

 

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?

Amit Gujarathi
Giga Sage
Giga Sage

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



Hi Amit,

That doesn't work. It seems like the font cannot be set when using the fillDocumentFieldsAndFlatten method.