-
-
Save nancystodd/bedc230611ec8f6d2209b3f3b7d1d1c7 to your computer and use it in GitHub Desktop.
ServiceNow PDF Generation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var UP3PDF = Class.create(); | |
UP3PDF.prototype = Object.extendsObject(AbstractAjaxProcessor, { | |
_document : null, | |
createPDF : function(html, table, sys_id, filename) { | |
var pdfDoc = new GeneralPDF.Document(null, null, null, null, null, null); | |
this._document = new GeneralPDF(pdfDoc); | |
this._document.startHTMLParser(); | |
this._document.addHTML(html); | |
this._document.stopHTMLParser(); | |
this._saveAs(table, sys_id, filename); | |
}, | |
_saveAs : function (table, sys_id, filename){ | |
var att = new GeneralPDF.Attachment(); | |
att.setTableName(table); | |
att.setTableId(sys_id); | |
att.setName(filename); | |
att.setType('application/pdf'); | |
att.setBody(this._document.get()); | |
GeneralPDF.attach(att); | |
}, | |
type: 'PDF' | |
}); | |
var p = new UP3PDF(); | |
p.createPDF('<p>Hello World!</p>', //HTML to convert to PDF | |
'incident', //Attach PDF to table | |
'85071a1347c12200e0ef563dbb9a71c1', //Attach PDF to record/sys_id | |
'myFile.pdf'); //attachment filename | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, I tried your code, though everything seems to be passing on the script include it's not generating the PDF
Getting the below error