DEV Community

Discussion on: How to make Pdf in React, Next js quickly

Collapse
 
bendeno profile image
Ben L. • Edited

I've used Puppeteer, which is headless chrome browser, to generate very rich document (graphic, chart, table, etc).

Use HTML, CSS, JS, and with what ever the data you need to inject into the document to generate a HTML document. Then feed that document to Puppeteer and use Puppeteer's print PDF function to generate the PDF file.

I did it a slightly different way. I wrote it in React, then feed that to React's Server Side Rendering (SSR) API to generate a HTML document and then feed the document to Puppeteer to print the PDF document.

I could have skipped the SSR step and feed React code directly into Puppeteer but that way I'd have needed to include all the libraries (including React) in the Puppeteer step.

Collapse
 
thangphan37 profile image
Phan Công Thắng • Edited

Thank you for the detailed sharing! I have just known a method for making PDF using Puppeteer. 😀