【问题标题】:HTML form to PDF using node.js使用 node.js 将 HTML 表单转换为 PDF
【发布时间】:2021-09-05 07:57:53
【问题描述】:

我想在 node.js 中编写一个程序,以便在我提交表单后,应使用用户输入的输入生成此表单的可下载 pdf。

  <form>
      <label for="name">Name:</label>
      <input type="text" name="name" id="name"  />
      <label for="email">Email:</label>
      <input type="email" name="email" id="email"  />
      <label for="contact">Contact Number:</label>
      <input type="phone" name="contact" id="contact"  />
      <label for="company">Organization:</label>
      <input type="text" name="company" id="company"  />
      <label for="designation">Designation:</label>
      <input type="text" name="designation" id="designation"  />

      <input type="submit">
    </form>

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: javascript html node.js


【解决方案1】:

您可以使用PDFKit

const PDFDocument = require('pdfkit');
const fs = require('fs');

const doc = new PDFDocument();
doc.pipe(fs.createWriteStream('output.pdf'));

doc
  .fontSize(25)
   // You can use the data as variables 
  .text(`PUT YOUR TEXT HERE AND USE THE DATA LIKE THIS: ${email}`, 100, 100);

doc.end();

【讨论】:

  • 好的。非常感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-11
  • 2019-10-24
  • 1970-01-01
  • 1970-01-01
  • 2019-08-19
相关资源
最近更新 更多