I am a creator — PDF Document Generator - Walter Brame

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014 08:09 PM
------------------
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.
!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2015 12:04 PM
Umer, I think that the UI Page and Macro implementation is the same:
// Begin script
// This holds your Jelly and HTML content
// and the Marco may be used by a UI Page to
// show the content in a UI Page
var uiMacroName= 'pdf_generator_mock'; // <===== REPLACE_ME !!!
/**
*
* This will create a PDF file using a UI Macro for the content
*
*
*/
var UIPage2PDF = Class.create();
UIPage2PDF.prototype = {
initialize : function(uiMacroName, glideRecord) {
// Get the rendered result of the HTML from the Jelly XML
var html = new GeneralFormFormatter({
name : uiMacroName,
root : glideRecord,
mode : 'pdf'
}).get().getValue('value');
// Create a PDF file by parsing the HTML
var pdf = new GeneralPDF(new GeneralPDF.Document(null, null, null,
html), null, glideRecord);
// _parse method should be changed to public if used this way
pdf._parse();
// Create an attachment for the PDF and add to the GlideRecord
GeneralPDF.attach(new GeneralPDF.Attachment(glideRecord.sys_id,
glideRecord.getTableName(), 'My PDF File', pdf.get(),
'application/pdf'));
},
type : 'UIPage2PDF'
};
/**
*
* Test it
*/
var glideRecord = new GlideRecord('u_pdf_document_generator_demo');
glideRecord.get('u_name', 'Testing 3');
new UIPage2PDF(uiMacroName, glideRecord);
// End script
But instead of a macro I think you can use UI Page as well since both would be almost the same.
Give it a try and let us know... cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 03:02 AM
Hi Walter,
Thanks for sharing this. I have downloaded and installed update set 1.3 for Eureka. When i click on Demo form and click on Create PDF for refreshes and takes me back to list view and when i click on Preview it opens a blank form.
Is there something i am not doing right ??
b.t.w. i have also tried this and installed 1.2 version on Calgary and have same response.
Any help will be appreciated,
Cheers
Syed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-23-2014 03:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2014 01:24 PM
Hey Walter,
I've successfully installed the application on a dublin instance (thank you for this appliation btw). I wanted to use this functionality on the pm_portfolio_project table in SN and have been able to modify the scripts successfully to do that. However, when generating a pdf, I'm only given one section of the form and not both form sections. After looking through the debug log, it appears both sections are passing as needed in the background but only the "default form section" is being added to the pdf itself. What am I missing?
Here is what I'm seeing in the debug log
15:10:31.673: : GeneralPDF.AddHTML Result =
|
| ||||||||||||||||||
| |||||||||||||||||||
|
|
15:10:32.0: : GeneralPDF.AddHTML Result =
|
|
|
while the pdf looks like this.....

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 01:25 AM
Is it possible to create a pdf file using some text string ? I have a record containing a text field field .. I want that text to be converted to a pdf file .