when we  export a pdf  from a custom workspace and a custom table I have few issues

kiran kumar m1
Tera Contributor

when we  export a pdf  from a custom workspace and a custom table I have few issues

1.my pdf is getting downloaded with the table name

2.I am able to see my table name on the pdf 

3.and in the workspace I have few html fields in that if I give bold text the text is coming as normal text in the pdf

 

can we change these three ?

 

kirankumarm1_0-1716532305586.jpeg

 

5 REPLIES 5

Abhit
Tera Guru

@kiran kumar m1 

How are you exporting this, by using OOTB export action or have you created your own custom action for it?

You can achieve it through custom solution:

Ref: https://www.servicenow.com/community/developer-articles/generating-custom-pdfs-using-the-new-pdfgene... 



@Abhit by using OOTB export action

In OOTB file name will come as table name followed by sys_id which is expected behavior.

I would suggest you to create a custom ui action and try the bellow code: or your can ref the link as well.


Update the field mapping.

var pageProperties = {
	HeaderImageAttachmentId: 'attachment_sys_id',
	HeaderImageAlignment: 'LEFT',
	PageSize: 'A4',
	GeneratePageNumber: 'true',
	TopOrBottomMargin: '72',
	LeftOrRightMargin: '36'
};

var html = '<p><span style="font-size: 12pt;">Complaint Details</span></p><table style="border-collapse: collapse; width: 34.169%; height: 125px;" border="1"><tbody><tr style="height: 15.3906px;"><td style="width: 39.782%; height: 15.3906px;"><span style="font-size: 10pt;">Report Title</span></td><td style="width: 60.218%; height: 15.3906px;"><span style="font-size: 10pt;">'+current.report_title+'</span></td></tr><tr style="height: 15.3906px;"><td style="width: 39.782%; height: 15.3906px;"><span style="font-size: 10pt;">Run Date and Time</span></td><td style="width: 60.218%; height: 15.3906px;">'+current.getDisplayValue("run_date")+'</td></tr><tr style="height: 15.3906px;"><td style="width: 39.782%; height: 15.3906px;"><span style="font-size: 10pt;">Run By</span></td><td style="width: 60.218%; height: 15.3906px;">'+current.getDiplayValue("run_by")+'</td></tr><tr style="height: 15.3906px;"><td style="width: 39.782%; height: 15.3906px;"><span style="font-size: 10pt;">Table name</span></td><td style="width: 60.218%; height: 15.3906px;">'+current.table.name+'</td></tr></tbody></table>';

new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDFWithHeaderFooter(html, current, current.sys_id, 'My First PDF', pageProperties, 'font_family_sys_id');



 

If I create the custom solution can I add the the pdf functionality in a UI button in workspace