【问题标题】:How to set top and bottom margin in .HTML using jspdf如何使用jspdf在.HTML中设置顶部和底部边距
【发布时间】:2021-01-19 17:05:46
【问题描述】:

如何在多页pdf中添加margin-bottom和top。

虽然我使用的是最新版本的 jspdf,它使用了 .html 函数

let doc = new jsPDF('p', 'pt', 'a4');
let myImage = '../../../assets/logo.png';
var margins = {
top: 40,
bottom: 60,
left: 40,
width: 522
    };

doc.html(document.getElementById('htmlData'), {
callback: function (pdf) {

pdf.output('dataurlnewwindow');
      },
    });

谢谢你的帮助

【问题讨论】:

    标签: javascript angular jspdf


    【解决方案1】:

    我认为您忘记将边距变量添加到 .html() 我将它添加为下面的数组。

    let doc = new jsPDF('p', 'pt', 'a4');
    let myImage = '../../../assets/logo.png';
    
    doc.html(document.getElementById('htmlData'), {
    // Adjust your margins here (left, top, right ,bottom)
    margin: [40, 60, 40, 60],
    callback: function (pdf) {
    
    pdf.output('dataurlnewwindow');
          },
        });
    

    【讨论】:

    • 谢谢你,只显示一件事我不想在页面html中显示内容
    • 我没有添加任何将在页面 html 中显示内容的代码。我只是尝试编辑需要在函数中放置边距数组的位置。
    • margin 属性被忽略,好像有buggithub.com/MrRio/jsPDF/issues/2924
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-01-04
    • 1970-01-01
    • 2019-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    相关资源
    最近更新 更多