【问题标题】:how can I control the font-size in html2canvas如何控制 html2canvas 中的字体大小
【发布时间】:2019-01-02 23:18:49
【问题描述】:

我正在使用 html2pdf 从 html 代码创建 pdf。它使用html2canvasjsPDF。结果非常好,但与原版略有不同:font-size 和 line-height 略有不同,因此页面末尾不正确。如果 div (具有在 A4 页面上正确呈现的固定方面),我真的需要一份副本。

有没有办法影响最终渲染中的字体?我现在制作pdf的方式是:

   savePdf () {
      this.pdfDialog = true
      let opt = {
        // if set firefox will not be able to print as pdf!...
        // margin: 0,
        filename: 'cv.pdf',
        enableLinks: true,
        image: { type: 'jpeg', quality: 0.98 },
        html2canvas: {
          scale: 8,
          useCORS: true,
          width: 310,
          letterRendering: true,
        },
        jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
      }
      html2pdf().set(opt).from(document.getElementById('printable-cv')).save()]
},

【问题讨论】:

    标签: jspdf html2canvas html2pdf


    【解决方案1】:

    解决方案是为元素添加内联样式。就我而言,在 vuejs 中工作我最终得到了以下代码:

    <div class="presentazione" v-html="presentation" :style="presentationFont"></div>
    

    【讨论】:

      猜你喜欢
      • 2012-05-05
      • 1970-01-01
      • 2015-12-02
      • 2016-05-24
      • 1970-01-01
      • 2015-05-05
      • 2014-09-23
      • 2013-01-06
      • 1970-01-01
      相关资源
      最近更新 更多