【问题标题】:How to send a html code as a arguement of function in PDFKIT node modules to genrate its pdf?如何发送 html 代码作为 PDFKIT 节点模块中的函数参数以生成其 pdf?
【发布时间】:2022-08-12 04:46:59
【问题描述】:

当我执行 .text() 时,PDFKIT 会在 pdf 中显示这个给定的文本。代码如下: -

const doc = new PDFDocument();

// pipe the document to a blob

常量流 = doc.pipe(blobStream());

// add your content to the document here, as usual

doc.fontSize(25).text(文本, 100, 100);

// get a blob when you\'re done

doc.end();

但是,我想知道可以将 html 代码作为参数并在 pdf 上呈现该 html 代码的函数。或建议任何其他方法,但仅使用 PDFKIT 模块。

    标签: pdfkit html-to-pdf node-pdfkit


    【解决方案1】:

    pdfkit 本身并不解释 HTML。还有另一个模块可以解析简单的 HTML。它可能会做你正在寻找的东西。

    https://www.npmjs.com/package/@shipper/pdfkit-html-simple

    【讨论】:

      猜你喜欢
      • 2017-05-15
      • 1970-01-01
      • 2020-08-07
      • 2019-06-03
      • 2023-03-04
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      相关资源
      最近更新 更多