将html表导出为pdf限制数据

时间:2018-03-05 15:50:47

标签: java php html css

输出总是单页一些数据请帮助我,谢谢你的行是60+但只有17个数据只是输出。

任何功能都可以在javascript中搜索我在线搜索但我找不到。

示例代码:

    <script type="text/javascript">
jQuery(function ($) {
    $("#exportButton").click(function () {
        // parse the HTML table element having an id=exportTable
        var dataSource = shield.DataSource.create({
            data: "#exportTable",
            schema: {
                type: "table",
                fields: {
                    Num: { type: Number },
                    Prodcut: { type: String },
                    unitPrice: { type: Number },
                    type: { type: String },
                    lastModified: { type: String },
                    Status: { type: String }
                }
            }
        });

        // when parsing is done, export the data to PDF
         dataSource.read().then(function (data) {
            var pdf = new shield.exp.PDFDocument({
                author: "PrepBootstrap",
                created: new Date()
            });

            pdf.addPage("a4", "landscape");
            pdf.table(
                50,
                50,
                data,
                [
                    { field: "Num", title: "Num", width: 30 },
                    { field: "Prodcut", title: "Prodcut", width: 200 },
                    { field: "unitPrice", title: "unitPrice", width: 90 },
                    { field: "type", title: "type", width: 200 },
                    { field: "lastModified", title: "lastModified", width: 90 },
                    { field: "Status", title: "Status", width: 50 }
                ],
                {
                    margins: {
                        top: 50,
                        left: 50
                    }
                }
            );

            pdf.saveAs({
                fileName: "Report"
            });
        });
    });
});

感谢您的建议。

Here the sample output

1 个答案:

答案 0 :(得分:0)

在空白处添加:

margins: {
             top: 50,
             left: 50,
             bottom: 50
         }