Take a screenshot of your React app and generate it as PDF

I would like to create a PDF from my React app, the simplest way would probably be to take a screenshot of the current state of my app / ideally a div and save it as a PDF ... I just don't seem to be able to find a better way like this to do.

Any ideas?

+3


source to share


1 answer


How about a combination:

html2canvas: https://html2canvas.hertzen.com/

and



jsPDF: https://parall.ax/products/jspdf

From the canvas provided by html2canvas, you can convert it to an image with .toDataUrl () and then pass it to jsPDF using the .addImage () method, which wants to get a base64 image.

+1


source







All Articles