Data Table customising pdf
datatables, jquery
Solution
Use the `customize` callback. It is not so well documented, see this answer for some references, or you could simply try to investigate the passed `doc` literal yourself. Basically
customize: function(doc) {
doc.defaultStyle.alignment = 'right';
doc.styles.tableHeader.alignment = 'right';
}
will end up in a PDF with right aligned headers and cell content. A sample could be
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [{
extend: 'pdfHtml5',
customize: function(doc) {
doc.defaultStyle.alignment = 'right';
doc.styles.tableHeader.alignment = 'right';
}
}]
})
demo -> https://jsfiddle.net/yzdtLz36/
Problem
I am using jQuery Data Table to export table as pdf.Now the pdf all the text are left aligned.How can I change it to right aligned?I need to add custom css to the exported pdf. Here is my code ``` $('#reporTable').DataTable({ "paging" : false, "ordering": false, "info" : false, "searching" : false, dom: 'T<"clear">lfrtip', tableTools: { "sSwfPath": "/javascripts/js/dataTables/tools/swf/copy_csv_xls_pdf.swf", "aButtons": [ { "sExtends": "pdf", "sTitle": filename, "sPdfOrientation": "landscape", "sPdfMessage": out_name+":" + msg }, ], } }); ```