convert-reactjs-html-to-pdf
📄 convert-reactjs-html-to-pdf is a React JS library for converting html to printable pdf with high quality and saving it locally.
With convert-reactjs-html-to-pdf you can include:
✔️ Images with high quality like logos, barcodes, QR codes, etc.
✔️ Applying external, internal and inline CSS
✔️ Resize PDF on generate
Example:
Installation
Use the package manager npm to install convert-reactjs-html-to-pdf.
npm i convert-reactjs-html-to-pdf
Usage
ℹ️ For best result set width: 600px;
and min-height: 840px
of desired element or set resize
to true
import { reactJsHtmlToPdf } from "convert-reactjs-html-to-pdf";
reactJsHtmlToPdf(element, name, resize, debug);
Options
Required
element: (string)
- Target HTML element based on document.querySelector(CSS selectors)
name: (string)
- Choose name for the file
Optional, default is false
resize: (boolean)
- If set to true
sets fixed size of A4 (width and min-height). ❗ Targeted element must be responsive for best result ❗debug: (boolean)
- If set to true
it's open generated PDF in new window for preview without automatically downloading it.
Demo
CSS selectors
License
MIT