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
08-03-2017 04:02 PM
Hello Karthik,
Seems to me that it is only passing in HTML information for the PDF. I would create a HTML header and HTML footer to append to the front and back of your HTML <p>Hello World!</p> message.
You can create an HTML header with inline styling like this example below:
<div class="body" style="font-family: Helvetica,Arial,sans-serif; font-size: 15px;">
<div class="topnav" style="background-color: #2d4c61; padding: 5px; float: left; width: 100%; color: #ffffff; verticle-align: middle;">
<div style="margin: 13px; display: inline-block; vertical-align: top;">Company</div></div></div>
Hope this helps.
Cheers,
Patrick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2017 02:13 AM
Hi Patrick
I tried passing the header and footer in the html but it doesn't print on every page. I looked at the script include GeneralPDF and has a variable this.headerimage. However, when I pass the image link it doesn't show up on PDF. Please let me know if you have any other ideas. Thanks for your response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2017 03:27 AM
Hi Karthik,
Did you find a solution for this? I`m facing the same issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2018 08:23 AM
If you have a personal instance, enable the HR module and check how it leverages the PDF creation there using templates and other artifacts.