The CreatorCon Call for Content is officially open! Get started here.

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 Chris,

Thanks for Replying for my question.

 

I went thru the same pain, tired zillion times to format the pdf with different way of styling. nothing worked, but only formatting with in cell of table seem to work.

So , i kind of created table cell with no borders for every line to be printed in PDF. This was final pdf format was same as that of template.

 

Regards

Hemashekar Reddy 

Hi Felipe,
 
I know this is really old post but I am working on something similar to this currently . Wear you able to solve this problem ??
 
I have been braking my head to generate the pdf with custom formatting and no matter what I try different way , the script is not honoring the styles from the template.
 
I would highly appreciate if you can share the solution for this if wear able to crack it.
 
Thank you so much.
 
Regards
Hemashekar Reddy

Reghuram
Kilo Expert

Hi Walter..



Here is the debug log :


15:10:32.653: *** Start #269,121, path: /u_pdf_document_generator_demo.do, user: reghu.jayachandran


15:10:32.656: com.glide.ui_list_edit.ListEditFormatterAction[dc1166036f5482009270f941be3ee4b2]=


15:10:32.667: Security restricted: Attempted access to restricted class name com.itextpdf


15:10:32.672: Evaluator: java.lang.SecurityException: Illegal attempt to access class 'com.itextpdf' via script Caused by error in Script Include: 'GeneralFormJava' at line 11 8: /** 9: * PDF API Suite 10: */ ==> 11: GeneralFormJava.iTextPDF = Packages.com.itextpdf; 12: GeneralFormJava.PdfName = GeneralFormJava.iTextPDF.text.pdf.PdfName; 13: GeneralFormJava.PDFTable = GeneralFormJava.iTextPDF.text.pdf.PdfPTable; 14: GeneralFormJava.PDFCell = GeneralFormJava.iTextPDF.text.pdf.PdfPCell;



Your solution : If the "Preview PDF" button displays an empty blank page it may be due to security. Try setting the "glide.whitelist.manager.collection_mode.override" system property to "true" and then try to use the application again. It is possible the system property does not exist on the instance and would need to be created. This is because certain Java Classes need to be added to the white list.



Can you please guide me to how to do this settings?


stanleylau
Kilo Explorer

Hi Walter,



I have do the implement to my own form, and it works.


But I find that the entire embedded list, and all the fields after that list(if any), are all truncated.


I try to use embedded list refering the same table(just like that in Demo) and it is alright to preview.


So, I'm wondering if the Generator do not support generating embedded list refering another form? Or, there is some setting needed to do before that?



Many Thanks


SwarnadeepNandy
Mega Sage

Hi Walter,


I am pretty much new to service now. In a CMS Page I am showing a report and a chart. I want to export both in a single PDF file. Individually I am able to export them as PDF, but I want both the report and the chart in a single PDF on click of a button.



Can I do that? If so, can you elaborate how?



Thanks in advance


Regards,


Swarnadeep Nandy