如何将HTML代码作为PDFKIT节点模块中的功能参数发送以生成其PDF?

发布于 2025-02-09 12:19:08 字数 398 浏览 3 评论 0 原文

当我做 .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模块。

When I do .text(<some text material>) then PDFKIT shows this given text in a PDF. This is my code:

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();

But, I want to know the function which can take html code as argument and render that html code on the pdf. Or suggest any other method but using PDFKIT module only.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

早乙女 2025-02-16 12:19:08

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文