DataTables.net-PDF导出报告自定义

DataTables.net-PDF导出报告自定义,pdf,datatables,export-to-pdf,pdfmake,Pdf,Datatables,Export To Pdf,Pdfmake,我无法设置PDF导出文档的边距。我尝试了很多东西和设置,但没有希望。 有兴趣帮助和解决此问题的人可以查看以下链接: $('#示例')。数据表({ dom:'Bfrtpi', 按钮:[ //“colvis”,//自定义列包括JShttps://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js //“colvisRestore”,//还原默认列包括JShttps://cdn.datatables.net/buttons/1.0.1/

我无法设置PDF导出文档的边距。我尝试了很多东西和设置,但没有希望。 有兴趣帮助和解决此问题的人可以查看以下链接:

$('#示例')。数据表({
dom:'Bfrtpi',
按钮:[
//“colvis”,//自定义列包括JShttps://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
//“colvisRestore”,//还原默认列包括JShttps://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
'pdf'、{//默认pdf和自定义pdf
扩展:“pdfHtml5”,
标题:'随机人',//报告标题/标题
定位:'景观',
页面大小:“A4”,
页面边距:[0,0,0,0],//尝试设置#1边距
边距:[0,0,0,0],//请尝试设置边距
文本:“导出页面(PDF)”,
键:{//按E键导出PDF
键:“e”,
altKey:错误
}
,内容:[{style:'fullWidth'}]
,样式:{//打印PDF正文的样式
全宽:{fontSize:18,粗体:true,对齐方式:'right',边距:[0,0,0,0]}
},
下载:'下载',
出口选择:{
修饰语:{
页边距:[0,0,0,0],//尝试设置3页边距
边距:[0,0,0,0],//尝试设置边距#4
对齐:“中心”
}
,正文:{margin:[0,0,0,0],pageMargins:[0,0,0,0]}//请尝试#5设置页边距
,列:[0,1]//列id在PDF中可见
,columnGap:1//可选列间距
}
}],
栏目:[
{
标题:'人名',
defaultContent:“”,//如果字段中未设置内容
数据:“名称”
},
{
标题:"人龄",,
键入:“num”,//这将是一个数字字段
数据:“年龄”
}
],
数据:[
{姓名:'John Doe',年龄:25},
{姓名:'迈克尔·杰克逊',年龄:30},
{姓名:'Tom Jones',年龄:32},
{姓名:'Monica Beluchi',年龄:34}
]
});

第一个链接比第二个链接描述得更多,但要点是相同的…

能否请您将代码缩短到一个仍然存在问题的最小示例?有很多代码与手头的问题无关,当有一个最小的示例时,其他人更容易调试。
    $('#example').DataTable({
    dom: 'Bfrtpi',
    buttons: [
        // 'colvis', // custom columns include JS    https://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
        // 'colvisRestore', // restore default columns include JS https://cdn.datatables.net/buttons/1.0.1/js/buttons.colVis.min.js
        'pdf', { // default PDF and customized PDF
     extend: 'pdfHtml5',
     title: 'Random Persons', // report header/title
     orientation: 'landscape',
     pageSize: 'A4',
     pageMargins: [ 0, 0, 0, 0 ], // try #1 setting margins
     margin: [ 0, 0, 0, 0 ], // try #2 setting margins
     text: '<u>E</u>xport Page (PDF)',
     key: { // press E for export PDF
         key: 'e',
         altKey: false
     }
     , content: [{ style: 'fullWidth' }]
         , styles: { // style for printing PDF body
                    fullWidth: { fontSize: 18, bold: true, alignment: 'right', margin: [0,0,0,0] }
         },
     download: 'download',
     exportOptions: {
         modifier: {
                     pageMargins: [ 0, 0, 0, 0 ], // try #3 setting margins
                 margin: [ 0, 0, 0, 0 ], // try #4 setting margins
             alignment: 'center'
         }
         , body : {margin: [ 0, 0, 0, 0 ], pageMargins: [ 0, 0, 0, 0 ]} // try #5 setting margins         
         , columns: [0,1] //column id visible in PDF    
         , columnGap: 1 // optional space between columns
     }
 }],
    columns: [
        {
            title: 'Person name',
            defaultContent: '', // if no content set in field
            data: 'name'
        },
        {
            title: 'Person age',
            type: 'num', // this would be a number field
            data: 'age'
        }
    ],
    data: [
        {name: 'John Doe', age: 25},
        {name: 'Michael Jackson', age: 30},
        {name: 'Tom Jones', age: 32},
        {name: 'Monica Beluchi', age: 34}
    ]
});