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

1.5k Views Asked by At

when I do .text() then PDFKIT shows this given text in a pdf . The code is given below :-

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 arguement and render that html code on the pdf . Or suggest any other method but using PDFKIT module only.

1

There are 1 best solutions below

1
Prdufresne On

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