Chandra Shekhar
Chandra Shekhar

Reputation: 1

How to send a html code as a argument of function in PDFKIT node modules to generate its pdf?

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.

Upvotes: 0

Views: 2544

Answers (1)

Prdufresne
Prdufresne

Reputation: 296

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

Upvotes: 0

Related Questions