如何将HTML代码作为PDFKIT节点模块中的功能参数发送以生成其PDF?
当我做 .text(<某些文本材料>)
然后pdfkit在pdf中显示此给定的文本。这是我的代码:
const doc = new PDFDocument();
// pipe the document to a blob
const stream = doc.pipe(blobStream());
// add your content to the document here, as usual
doc.fontSize(25).text(text, 100, 100);
// get a blob when you're done
doc.end();
但是,我想知道可以将HTML代码作为参数并在PDF上渲染的功能。或建议任何其他方法,但仅使用PDFKIT模块。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PDFKIT本地不会解释HTML。还有另一个可以解析简单HTML的模块。它可能会做您想要的。
pdfkit doesn't interpret HTML natively. There is another module that can parse simple HTML. It may do what you're looking for.
https://www.npmjs.com/package/@shipper/pdfkit-html-simple