why "GeneralPDF" not working, getting error like GeneralPDF not defined
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
6 hours ago
Hi All,
Kindly let me know why GeneralPDF not working
Error :
gs.addErrorMessage("PDF generation failed: " + e.message);
GeneralPDF not defined.
Client SCript :
var responseBody = Contenthtml;
var letterheadHTML =
"<html xmlns:o='urn:schemas-microsoft-com:office:office' " +
"xmlns:w='urn:schemas-microsoft-com:office:word' " +
"xmlns='http://www.w3.org/TR/REC-html40'>" +
"<head><meta charset='utf-8'></head>" +
"<body>" +
"<div style='font-family: Calibri, sans-serif; padding: 40px; line-height: 1.6;'>" +
"<div style='text-align: right; margin-bottom: 30px;'>" +
"<img src='https://dev351275.service-now.com/customer_service_email_logo.png' style='width: 100%; max-height: 120px;' alt='Header Image'>" +
"</div>" +
"<div>" +
"<p><strong>Date:</strong> " + new Date().toLocaleDateString() + "</p>" +
responseBody +
"</div>" +
"<div style='text-align: center; margin-top: 50px;'>" +
"<img src='https://dev351275.service-now.com/customer_service_email_logo.png' style='max-height: 80px; max-width: 300px;' alt='Footer Image'>" +
"</div>" +
"</div>" +
"</body>" +
"</html>";
var ga2 = new GlideAjax('global.AttachToRecord');
ga2.addParam('sysparm_name', 'getPDF');
ga2.addParam('sysparm_recordSysId', taskSysId);
ga2.addParam('sysparm_tableName', tableName);
ga2.addParam('sysparm_htmlContent', letterheadHTML);
ga2.addParam('sysparm_ filename', 'Welcome.pdf');
ga2.getXMLAnswer(function(response) {
alert('PDF Attachment created successfully!');
});
Script Include : GeneratingPDF(custom)
var GeneratingPDF = Class.create();
GeneratingPDF.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getPDF: function() {
var table = this.getParameter('sysparm_tableName');
var sysId = this.getParameter('sysparm_recordSysId');
var htmlContent = this.getParameter('sysparm_htmlContent');
var filename = this.getParameter('sysparm_ filename');
this.createPDF(htmlContent, table, sysId, filename);
},
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: 'GeneratingPDF'
});
0 REPLIES 0