Is it possible to Export PDF form with custom header/footer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 10:13 AM
Hi ,
We have platform offering "Export to PDF" in which I need to add custom header/footer.
I need to display company logo in the header and some confidential note in footer. Please let me know if any thoughts.
- Labels:
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 10:51 AM
Yes, there is a PDF API:
Requires an HTML template, from an HTML Script type field, or hand hacked. Can add header, footer and logo.
Aoife
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 11:00 AM
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
04-07-2022 11:43 AM
Joro,
If you please, start posting code using the {;} code insert button on the editor, it makes it look much nicer and more readable. Also, be sure to select the proper type once in the code editor.
Like this:
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'
});
Aoife
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2022 12:24 PM
You have a point - noted and fixed!