小编Man*_*038的帖子

调整DataTable pdf导出的列宽

我已经去过这个线程Set Column width when exporting to pdf when using datatables net但它已经快一年了,并没有解决我的问题。我想在以 pdf 格式导出 DataTable 时调整我的列的列宽。我试过这个,但没有任何改变:

$('#table').dataTable({
    "dom": '<"top"f>tiB',
    paging: false,
    fixedHeader: {headerOffset: 45},
    buttons: [
    {
        extend: 'pdfHtml5',
        exportOptions: {
            columns: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
        },
        customize : function(doc) {
            doc.styles['td:nth-child(8)'] = { 
                width: '1000px',
                'max-width': '1000px'
            }
        },
        text: 'Export: PDF',
        orientation: 'landscape',
        pageSize: 'A3',
    }]
});
Run Code Online (Sandbox Code Playgroud)

包含 pdfmake.js,我也尝试过width: 1000"width: 1000"类似的东西。

css pdf jquery datatables

6
推荐指数
1
解决办法
5422
查看次数

标签 统计

css ×1

datatables ×1

jquery ×1

pdf ×1