Adding an Image (company logo) to a PDF using GeneralPDF.

scott_s
Kilo Contributor

I am having issues with trying to get an image displayed at the top of a PDF being created using the GeneralPDF Script Include on a Kingston instance. GeneralPDF was chosen for this task because it could take HTML as input and add the resultant PDF as an attachment to any record.
At first I had issues with GeneralPDF ignoring stylesheets and actually printing rather than rendering any inline <style> blocks. I found that I had to set all the style attributes on the individual elements to get it to format reasonably. But the company logo still does not show. I have found several posts in the community on this subject but none that have an answer that works with GeneralPDF. The GeneralPDF.Document constructor takes a headerImage as a parameter but documentation on using this property is non-existent. I had tried passing values to it as others have tried before but like the others I had no luck with this.

Does anybody have a solution that works with adding a header image or any image to a PDF using the GeneralPDF APIs?
Can anyone point me to official documentation on using GeneralPDF in S/N?
Does anybody have another solution that can produce a PDF document with any S/N API that can take HTML input and include an image on the page?

The end goal is to create a PDF document from data provided in HTML format, including a company logo, and save it as an attachment.

Any help on this subject would be greatly appreciated.
We have a deadline coming due and I cannot waste any more time trying to get GeneralPDF to work when it may not even be possible.

Thank you

3 REPLIES 3

Jeff Currier
ServiceNow Employee
ServiceNow Employee

Patrick has a good suggestion in this post.  Have you tried this one.  I know you said you saw some, but this seems GeneralPDF specific

Thanks for the response Jeff. I had gone down that direction a bit but stopped because I ran into another roadblock. I did my initial testing in the global app but I need to use this in a scoped app. When I tried to use it from the scoped app, I got "GeneralPDF not found" errors because it is not marked for use by all application scopes. I tried marking it for all application scopes but that created other errors in the low-level java code. So, at this time, I have given up on the idea of having a PDF generated from the HTML source in ServiceNow. Thanks again for your response. When I get some free time (?) I will revisit this.

Fabian Kunzke
Kilo Sage
Kilo Sage

Hey,

i might be really late to the party, but ServiceNow now has a new API for that. This article goes into more detail.

Regards

Fabian