A basic Electron React app that uses react-to-print library to print individual components.
Implementation of print
method for print-to-react is the crux of the demo. See handlePrint
method in App.js
. Also, See App.css
for CSS print settings.
This uses React function components. If you wish to see the implementation using class components then use branch class_components.
Download and extract the project. Run following commands in the root dir:
-
Run
npm install
-
Run
npm run dev
to start webpack-dev-server. Electron will launch automatically.
To test the app following print to PDF printers can be used:
- On Linux use CUPS-PDF
- On Windows use Microsoft print to PDF
Note: All the dependencies have been updated to the latest versions available on 4th September 2022.
❯ npm ls
[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]