每个页面都显示相同的内容吗?

时间:2019-03-23 07:14:38

标签: javascript jspdf

我正在处理多页的jsPDF。我无法在页面上添加页眉和页脚,并且在每个页面中显示的内容都是相同的。

有人可以帮我犯什么错误吗?

generatePDF() {
    let doc = new jsPDF('p', 'mm', 'a4');

    let content = this.finalContent;

    let pageHeight = 295;

    let image = content["image"];
    let width = content["width"];
    let height = content["height"];

    let imgHeight = height;

    let heightLeft = imgHeight;
    let position = 0;

    doc.addImage(image, 'JPEG', 10, 30, width, height);

    heightLeft -= pageHeight;

    while (heightLeft >= 0) {
        position = heightLeft - imgHeight;
        doc.addPage();
        doc.addImage(image, 'JPEG', 10, position, width, imgHeight);
        heightLeft -= pageHeight;
    }
    doc.save("test.pdf");
}

0 个答案:

没有答案