How to generate a .pdf output, with a pre-defined look and feel?

JV2
Tera Expert

Our client is asking for generating a pdf, with a pre-defined look and feel.

For example, if we have a form like the one attached here (this is just an example, randomly taken form internet), we could generate a form in ServiceNow to capture that information and apply any flow to it. Now, when it comes to printing that form from ServiceNow, the client wants to generate the exact look and feel as the original form. Has anyone faced this kind of requests? Please advise.

find_real_file.png 

8 REPLIES 8

...you can build a form in ServiceNow that upon submission, etc. can fill that PDF in for you on their behalf

 

This is what we are looking for. We know what the user wants; we are looking for how to fulfill that requirement, if possible.

Hi JV,

Ok, great. You can build a form (perhaps a catalog item that can be submitted and auto-fulfilled by offering the now filled PDF through the associated workflow run script activity and attaching it to their request item record) or some other method of a form to capture the data, that is then set to run this script afterward and attach it for them.

You'd then utilize the GeneralPdfUtils() API using the methods/script from this post here: https://community.servicenow.com/community?id=community_blog&sys_id=4acc6265dbd0dbc01dcaf3231f961949

GeneralPdfUtils became standard with ServiceNow back in Jakarta. So it's all available to you OOTB.

My personal suggestion is to use a website/application like "PDFescape" where you can load your PDF, see the fillable fields, unlock them by right-clicking on the field, then right-click again to see the properties and grab the PDF field name. Use that in the script above to fill it in, Here's an example of building out your JSON object:

var jsonObj = {
"topmostSubform[0].Page1[0].Step1a[0].f1_01[0]": current.getDisplayValue('first_name'),
"topmostSubform[0].Page1[0].Step1a[0].f1_02[0]": current.getDisplayValue('last_name'),
"topmostSubform[0].Page1[0].Step1a[0].f1_03[0]": current.getDisplayValue('street')
};

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi,

I just wanted to check-in on this. If my reply above helped guide you correctly, if you don't mind, please mark it as Helpful & Correct.

Thank you!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

asifnoor
Kilo Patron

Hi,

I think the easiest way to do this is to have the data store in the database. Then read the data in a BR and build a html layout with the data substituted in the placeholders.

Then convert the html to PDF using the 3rd party options available on the internet.

 

I suggest html so that there is flexibility to play around with the layouts and can also include css for styling.