1 year ago

#166787

test-img

Domenico Santoro

Node.js How to add wkhtmltopdf result to PDFKit page?

Is there a way to concat the result of an an html page converted with wkhtmltopdf-node inside a document page created with pdfkit in node.js, instead of just creating a pdf file from html?

const doc = new PDFDocument({
  bufferPages:true,
  toc: true,
  margins: {
    top: 125,
    bottom: 50,
    left: 50,
    right: 50
    }
});
    

doc.pipe(fs.createWriteStream('output.pdf'));

doc.addPage();
doc.text("HTML Content ")

// concat the result of this conversion inside doc instead of out.pdf
wkhtmltopdf(params.content, { pageSize: 'letter' }).pipe(fs.createWriteStream('out.pdf'));

Something like

doc.concat(wkhtmltopdf(params.content, { pageSize: 'letter' }));

node.js

wkhtmltopdf

node-pdfkit

0 Answers

Your Answer

Accepted video resources