Convert React custom component with stylings into PDF and download file

1.8k Views Asked by At

As title says, I have to convert React component into PDF document and then be able to download it. Final PDF document should be consisted of 4 pages, where every page is one React component. These React components are very customized (including QR codes and so on). I tried react-pdf/rendered but problem is that their Document component accepts only predefined components from their library (Page, Document, View, etc.) and I can't create desired components with them. Also, take into account that I'm using Typescript so no all available libs from NPM can be used, because not all of them have TS support. Any help?

1

There are 1 best solutions below

1
On

If I understand well, what you need is to export a part of your UI or a Component to PDF, if it is what you are aiming you can try html2canvas: https://html2canvas.hertzen.com/

If it's not what you want please clarify.