The CreatorCon Call for Content is officially open! Get started here.

Certain HTML styles are not loading in GeneralPDF.Document

Joey Wan Kenobi
Tera Guru

Hello,

I created a script include that provides a create PDF functionality using the OOTB GeneralPDF script include. It successfully creates the document and attaches it to the ticket.

Some styles, however, are not being applied (for example, 'background-color' on <td> and border on <table>). Is it possible to get these styles to apply? If so, how? Has anyone had success doing so? I looked at the OOTB GeneralPDF script include, and it is almost as if it wasn't finished.

Here are the main functions in the script include that I created:

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);

},

9 REPLIES 9

venkatiyer1
Giga Guru

I see that the generatePDF script includes has the script section that load styles commented. I have not personally used this tool


but i would create a UI page that has all the styles embedded into the tag itself as style attributes and render that UI page in the pdf.




The reason being I had created a Custom PDF solution using Mid server and I noted that it was very tough to make iText


render the css styles if you were to specify them in a CSS stylesheet rather than html attributes.



But still a good question for HI too.


I'm not familiar with rendering a UI page in a PDF. How does that work?


This data in this PDF is pulled from an SN record as well. Not sure how that would work either.


My solution Customized Print Solution using MidServer   actually has parts which would help understand as to how you can have the UI page and how you coudl render it using the OOB Generate PDF script.


I had created this solution prior to the GeneratePDF so you can use the OOB but customize it accordingly.