简体   繁体   English

节点 | npm : html-pdf,设置图片大小

[英]Nodejs | npm : html-pdf,set image size

I'm using html-pdf to convert an SVG file to PNG, and I can't get the output image size to reflect the input size (128x128).我正在使用 html-pdf 将 SVG 文件转换为 PNG,但我无法获得输出图像大小来反映输入大小 (128x128)。 Instead it comes with blank space (see image below).相反,它带有空格(见下图)。 I've tried explicitly setting width and height, setting header and footer height (as per this link<\/a> ), but nothing has any effect.我已经尝试明确设置宽度和高度,设置页眉和页脚高度(根据此链接<\/a>),但没有任何效果。

Any suggestions?有什么建议?

在此处输入图像描述<\/a>

Code:代码:

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

I ended up using npm:sharp .我最终使用了npm:sharp

Worked perfectly.工作完美。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM