how to add pdfmake script to datatable


how to add pdfmake script to datatable



I'm trying to work with DataTables Export feature, Now my current requirement is to export a custom pdf (change the font size, color, etc.). In the DataTable documentation, it states, that we can integrate it with PDFmake, which I am unable to do so. Thus my question is,



how to apply this to datatable when exporting pdfmake?


var dd = {
content: [
{
text: 'This paragraph uses header style and extends the alignment property',
style: 'header',
alignment: 'center'
},
{
text: [
'This paragraph uses header style and overrides bold value setting it back to false.n',
'Header style in this example sets alignment to justify, so this paragraph should be rendered n',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Malit profecta versatur nomine ocurreret multavit, officiis viveremus aeternum superstitio suspicor alia nostram, quando nostros congressus susceperant concederetur leguntur iam, vigiliae democritea tantopere causae, atilii plerumque ipsas potitur pertineant multis rem quaeri pro, legendum didicisse credere ex maluisset per videtis. Cur discordans praetereat aliae ruinae dirigentur orestem eodem, praetermittenda divinum. Collegisti, deteriora malint loquuntur officii cotidie finitas referri doleamus ambigua acute. Adhaesiones ratione beate arbitraretur detractis perdiscere, constituant hostis polyaeno. Diu concederetur.'
],
style: 'header',
bold: false
}
],
styles: {
header: {
fontSize: 18,
bold: true,
alignment: 'justify'
}
}
}



this is my datatable script:


$(document).ready(function() {
$('#globaldatatable').DataTable({
scrollX: '100%',
scrollY: 400,
iDisplayLength: '100',
ordering: false,
bPaginate: false,
sDom: '<"row"<"col-sm-6"B><"col-sm-6">>' + '<"row"<"col-sm-12"<"table-responsive"t>>>' + '<"row"<"col-sm-5"><"col-sm-7">>',
buttons: {
buttons: [
{ extend: 'pdfHtml5',
text: '<i class="fa fa-file-pdf-o"></i> PDF',
className: 'excelButton',
orientation: 'landscape',
title: 'Laporan Detail Karyawan',
pageSize: 'A4'
},
{ extend: 'excelHtml5',
text: '<i class="fa fa-file-excel-o"></i> EXCEL',
className: 'excelButton',
title: 'Laporan Detail Karyawan',
message: $('#printed').text()
}],
dom: {
container: {
className: 'dt-buttons'
},
button: {
className: 'btn btn-default'
}
}
},
"columnDefs": [ { "width": "5%", "targets": 0 } ]
});
});





Possible duplicate of DataTables & PDFmake
– Alexander
Jul 3 at 6:46





yea man, its hard making sentence for question because its almost code so cant post it, and that answer doest help me
– Alvin
Jul 3 at 6:52










By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

api-platform.com Unable to generate an IRI for the item of type

How to set up datasource with Spring for HikariCP?

PHP contact form sending but not receiving emails