Add a footer in the PDF file of datatables
Add a footer in the PDF file of datatables
Hi All,
We are using DataTable plugin in our web application to display our tables, download PDF files and so far its working really nice. And thank you very much for this amazing plugin.
And now we want to add a description as the footer for each PDF file which are downloaded. We tried "sPdfMessage" to give a description but it display the description just above the PDF file's table. We need to display that description at the bottom of the PDF.
Is it possible to change the "sPdfMessage" position as the bottom of PDF file or can we add a footer for the PDF file using the API?
Thanks in Advance.
Answers
Or can anyone please tell me how to do a workaround in TableTools.js to add a description at the bottom of PDF file?
I tried to append a string at the last of fnSetText function below, but it appended to the last cell of table.
js
"pdf": $.extend( {}, TableTools.buttonBase, {
"sAction": "flash_pdf",
"sNewLine": "\n",
"sFileName": "*.pdf",
"sButtonClass": "DTTT_button_pdf",
"sButtonText": "PDF",
"sPdfOrientation": "portrait",
"sPdfSize": "A3",
"sPdfMessage": "",
"fnClick": function( nButton, oConfig, flash ) {
this.fnSetText( flash,
"title:"+ this.fnGetTitle(oConfig) +"\n"+
"message:"+ oConfig.sPdfMessage +"\n"+
"colWidth:"+ this.fnCalcColRatios(oConfig) +"\n"+
"orientation:"+ oConfig.sPdfOrientation +"\n"+
"size:"+ oConfig.sPdfSize +"\n"+
"--/TableToolsOpts--\n" +
this.fnGetTableData(oConfig)
);
}
} ),
Hi all,
I have done this. I have modified the swf file for adding header image and footer text.
Hi Ramesh,
Thank you very much for the comment. Can you please tell us the things you have modified and give more information about it?
Hi Visitha,
First download the swf code from https://github.com/DataTables/TableTools/tree/master/as3 and download the flex 4.6 sdk.
and then modify the ZeroClipboardPdf.as file using any flash editor or using Notepad++, you will find java code inside that file.
Change the position of "message" property then compile the as file using following command
mxmlc -static-link-runtime-shared-libraries=true -library-path=C:\flex_sdk_4.6\frameworks\libs ZeroClipboardPDF.as
It will generate swf file and rename this swf file with "copy_csv_xls_pdf.swf" and use this swf in your project.
Hi ramesh joshi,
Can you please share the code(.as) to add logo in the pdf. I have add the footer text,but i cant able to add the logo image at the top.
I am using a workaround and putting my logo and disclaimer in the footer e.g.
It doesn't look very good as a pdf, but I have disabled that option because I am also changing the cell color based on value and that's also not coming through in pdf. So I am letting people use the print option and then print to pdf.