Generate PDF with Header Image
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-03-2017 01:07 PM
I have a requirement to generate pdf and attach it to a record. I've used OOB GeneralPDF script include and achieved that (code below). However, I am unable to pass header image and footer text. Any suggestions on how to pass header/footer ? Thanks in advance.
var PDF = Class.create();
PDF.prototype = Object.extendsObject(AbstractAjaxProcessor, {
_document : null,
example : function (){
this.createPDF('<p>Hello World!</p>', //HTML to convert to PDF
'incident', //Attach PDF to table
'd324db7d2b9aa20072675aa419da1547', //Attach PDF to record/sys_id
'myFile.pdf'); //attachment 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: 'PDF'
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2019 01:30 PM
Hello Karthik, I am in similar situation and need to create pdf from html. however i am stuck at pdf generation. I tried your code but its not working.
I am holding all html content in a variable in business rule and want to print pdf and attach it to a record. Any help is appreciated.