【问题标题】:Nodejs | npm : html-pdf,set image size节点 | npm : html-pdf,设置图片大小
【发布时间】:2022-02-10 22:24:16
【问题描述】:

我正在使用 html-pdf 将 SVG 文件转换为 PNG,但我无法获得输出图像大小来反映输入大小 (128x128)。相反,它带有空格(见下图)。 我试过明确设置宽度和高度,设置页眉和页脚高度(根据this link),但没有任何效果。

有什么建议吗?

代码:

htmlpdf.create(qrcode, { "border": "0", "type": "png"}).toFile(originalname.split(".")[0]+".png", function(err, res) {
        if (err) throw err;
        console.log(res);
      });

【问题讨论】:

    标签: node.js html-pdf


    【解决方案1】:

    要解决上述问题,您可以使用名为:npm:sharp 的 npm 包。

    它完美地解决了上述问题。

    【讨论】:

      猜你喜欢
      • 2018-02-17
      • 2018-05-08
      • 1970-01-01
      • 2023-03-26
      • 2020-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多