【问题标题】:Exporting html table to pdf limit data将html表格导出为pdf限制数据
【发布时间】:2018-08-13 08:03:50
【问题描述】:

输出总是一页,一些数据请帮助我,谢谢,行是 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

【问题讨论】:

    标签: java php html css


    【解决方案1】:

    在空白处添加:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多