1

我将 bootstrap-table 插件与 tableExport 插件(https://github.com/hhurz/tableExport.jquery.plugin)一起使用。

我设法导出了我的表格,但我想在表格本身之前在 PDF 中添加一个标题。这是我的代码:

$("#table").bootstrapTable({
    exportOptions: {
        fileName: 'export_anim',
        worksheetName: 'table',
        csvSeparator: ';',
        jspdf: {
            orientation: "l",
            autotable: {
                styles: {rowHeight: 14, fontSize: 8, fillColor: 240},
                headerStyles: {fillColor: 255, textColor: 0},
                alternateRowStyles: {fillColor: 210, textColor: 0}
            }
        }
    }
});

有什么办法可以做到这一点?

4

1 回答 1

1

一种方法是将beforePageContent钩子与marginautotable 中的选项一起使用。像这样的东西:

autotable: {
    margin: {top: 80},
    beforePageContent: function (data) {
        var doc = data.doc; // Internal jspdf instance
        doc.setFontSize(20);
        doc.setTextColor(40);
        doc.setFontStyle('normal');
        doc.text("Table Title", data.settings.margin.left, 60);
    }
}

请注意,您需要jspdf-autotable >=2.0.33. 有关更多信息,请查看 autotable 页眉和页脚演示代码

于 2016-08-01T12:43:33.203 回答