相关疑难解决方法(0)

jsPDF/html2canvas 通常会丢失空格和文本错位

我正在使用 html2canvas 和 jsPDF 生成 pdf 客户端。无论我选择什么设置,我都会在 html 到 pdf 渲染中丢失字母空格。

有设置可以解决这个问题吗?我已经检查了 API 并更改了我能想到的所有可能的设置,但间距没有改变。

显示空间损失的图像

之前(在浏览器中为 html):

在此输入图像描述

之后(pdf):

在此输入图像描述

代码

代码使用 html2canvas 和 jsPDF。

async pdfOrder() {
    const doc = new jsPDF({
      orientation: "p",
      unit: "mm",
      format: "a4",
      precision: 5
    });
    const options = {
      background: "white",
      scale: 3
    };

    for (let i = 0; i < this.numberOfPages; i++) {
      const div = document.getElementById("html2Pdf-" + i.toString());
      // create array of promises
      await this.addPage(doc, div, options, i);
    }

    // Name of pdf …
Run Code Online (Sandbox Code Playgroud)

html2canvas jspdf angular

6
推荐指数
1
解决办法
4499
查看次数

标签 统计

angular ×1

html2canvas ×1

jspdf ×1