我正在尝试使用DataTables导出功能,现在我的当前要求是导出自定义pdf(更改字体大小,颜色等)。在DataTable文档中,它指出我们可以将其与PDFmake集成,但我无法做到这一点。因此,我的问题是,
导出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'
}
}
}
这是我的数据表脚本:
$(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 } ]
});
});