I am a creator — PDF Document Generator - Walter Brame

walter_brame
ServiceNow Employee
ServiceNow Employee

------------------

EDIT

------------------

A lot has changed over the years.

Be sure to check here first:

https://developer.servicenow.com/dev.do#!/reference/api/quebec/server/sn_pdfgeneratorutils-namespace/CellBothAPI?navFilter=pdf

Have also enjoyed repurposing Webkit HTML to PDF plugin:

https://docs.servicenow.com/bundle/geneva-performance-analytics-and-reporting/page/use/performance_analytics/task/t_ActivateWHTP.html

------------------

ORIGINAL

------------------

PDF Document Generator is used by the ServiceNow, Inc. sales organization and is a generic HTML form creation and PDF Document generation framework.   The framework supports creating HTML forms and PDF files using any UI Form in the instance as a template.

 

The PDF Document Generator will replicate how that standard UI Form looks but then provides the functionality to change it easily as a front-end user without requiring development.

 

A PDF feature exists today in the standard platform but it is not customizable. The PDF Document Generator allows for rapid deployment of multiple templates and making changes on the fly to every component visible on the screen very quickly and easily.

 

Previously, the Sales organization was challenged with the ability to produce Quotes and Sales Orders from a CRM environment. With this custom ServiceNow, Inc. app in place, it is now possible for the front-end business users (sales operations, systems managers, administrators, power users, non-developers) to access configuration tools that put control of the following features directly into their hands:

 

- Add/remove fields as needed

- Change any fields placement and the field's label, orientation, or value

- Change any section/grouping or fields / Table of information (E.g. "Section 1", "Section 2", etc.)

- Add/remove new sections present in the form

- Manage an entire section's placement, splits, annotations, and headers

- Re arrange the placement of components in the form (E.g. one component relative to the next)

- Change the look and feel (color, border, padding, alignment, etc.) via common HTML and CSS style attributes.

- A scripting API to create dynamic conditions to change any aspect of the form and data (style, value, label, section, etc.).

- Save templates of form layouts

- Preview and print to PDF

 

The functionality of this PDF Document Generator was made possible by leveraging the ability to write custom scripts in the standard ServiceNow platform, and by having access to the backend table structure and data where forms are stored in the instance (standard UI page, CSS, HTML, and JavaScript).   A single developer, in a time frame of one business quarter, built the PDF Document Generator.

 

pdf_doc_gen_img_1.png

pdf_doc_gen_img_2.png

pdf_doc_gen_img_3.png

pdf_doc_gen_img_4.png

pdf_doc_gen_img_5.png

pdf_doc_gen_img_6.png !

 
99 REPLIES 99

Hi Sanjeev,



If you can turn on the "debug log" module and then view the page it will display an error message if there is any at the bottom of the page. If you can send me that output I may be able to help determine what is wrong with the application.



There is a specific update set just for Calgary, support file "sys_remote_update_set_a97ef4fd75382100178e0ebe2386e29d". Can you confirm is this the update set you installed and did the update set preview report any issues? If the update set reported any issues please share those as well if possible.


Hi Sanjeev,



Have you got solution of your posted query. I'm trying to execute same demo form but getting "Illegal attempt to access class 'com.itextpdf' via script" error while opening "Testing1" form. I'm using Eureka version.


Kindly share if your got any solution of this.



Thanks in Advance


Regards


Arun Kumar


xif1
Mega Expert

Amazing walter.



But i've a little probleme. It's working but i've tried to modify some field in PDF preview and now, everytime, when I click on it i've this message:



The entity "nbsp" was referenced, but not declared.


I can generate my pdf but not preview and modify as usual...


You have a solution ?



EDIT : it seems that when an error is detected, you show it in the entire page, impossible to edit the script box behind...


walter_brame
ServiceNow Employee
ServiceNow Employee

Hi Romain,



That error message is telling us that the "UI Page" is not getting an escaped value for a white space character. Specifically a white space will turn into "   " in HTML however the "UI Page" wants the ampersand declared as " & " making an escaped HTML Entity for a white space turn into " &ampnbps; ".



The application is escaping any values you enter by editing fields or Annotations in the Form Layout but maybe you found another way to add values that are not being escaped. Most likely if you can identify the change you made in the form and un do it that will resolve the issue. Possible you added an HTML field and edited there or you edited some Annotations in the Form.



If you can give me some details about the type of change you made to the form just before it started having this issue I can use that to try and reproduce the issue on my side. In the mean time Ill see if I can find a scenario where a value added by a user in the Form is not being escaped.



If you are able to turn on debugging and find an error message please provide that as well. Also let me know if you are using the Calgary or Dublin version.



It should be possible to give you a updated version of the "UI Page" that will attempt to render the HTML in blocks so it can skip a bad block and help more easily see which part of the Form has a problem. Will get back to you with this.



Thanks


Hi Walter, Thank for your quick anwser,



I've reinstalled your API, so as the first time, my creation work but not the preview after customisation.



My new error is Attribute name "align" associated with an element type "td" must be followed by the ' = ' character.


i've just added align='justify';


In preview html script box...before that it worked. But with this error, I can't modify this line because everytime when I click on "preview" i've a blank page with this message. How can I bypass the error message for edit my box in preview mode ?