dwk-pdf
v0.2.1
Published
PDF generation for Dynamic HTML on WebKit. Translate docx to HTML.
Downloads
3
Maintainers
Readme
DWKPdf
Generate PDF files from Docx or HTML. (bundle of: ejs, mammoth, wkhtmltopdf)
For work install wkhtmltopdf
(in fedora dnf install wkhtmltopdf
)
Example:
// Import
const { DWKPdf } = require('dwk-pdf'); // CommonJS
import { DWKPdf } from "dwk-pdf"; // ESM
// Create a new DWKPdf instance
const pdf = new DWKPdf(`<p><%= name %></p>`); // from html
const pdf = DWKPdf.fromDocx(docxBuffer, {}, {}); // from docx
const pdfStream = await pdf.render({
name: "My name",
});
await pdfStream.pipe(fs.createWriteStream("test.pdf"));