Background color is not being applied in HTML template for PDF generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 04:42 AM
Background color is not being applied in HTML template for PDF generation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 04:44 AM
Hi Vidushi,
How are you generating the html template?
Is it some custom code or out of box?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 10:23 PM
Ankur,
The code is custom.
We are generating PDF on UI action in which I am rendering HTML page and also replacing values from table's field after that I am using below script include to generate PDF:
Script Include:
var CustomPDFUtility = Class.create();
CustomPDFUtility.prototype = {
initialize: function() {
},
process : function(htmlPayLoad,tableName,sysID) {
gs.info("Invokedd >>>>>> ");
var payload = htmlPayLoad.toString();
this.createPDF(payload, //HTML to convert to PDF
tableName, //Attach PDF to table
sysID, //Attach PDF to record/sys_id
'Service_Forum.pdf'); //attachment filename
},
createPDF : function(html, table, sys_id, filename) {
var pdfDoc = new global.GeneralPDF.Document(null, null, null, null, null, null);
this._document = new global.GeneralPDF(pdfDoc);
this._document.startHTMLParser();
this._document.addHTML(html.toString());
this._document.stopHTMLParser();
this._saveAs(table, sys_id, filename);
},
_saveAs : function (table, sys_id, filename){
var att = new global.GeneralPDF.Attachment();
att.setTableName(table);
att.setTableId(sys_id);
att.setName(filename);
att.setType('application/pdf');
att.setBody(this._document.get());
global.GeneralPDF.attach(att);
},
type: 'CustomPDFUtility'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 10:44 PM
Hi Vidushi,
Since this is custom code you need to check which line of code is responsible for background color and accordingly debug
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-12-2018 10:58 PM
I have not used GeneralPDF before. However, other PDF generators I have used only recognised older CSS methods.
For example:
Instead of <td style="background-color:#ffffcc;">
Try <td bgcolor="#ffffcc">