Pdfkit import fails in Electron
See original GitHub issueBug Report
Description of the problem
I am trying to import pdfkit in Electron. I have been using Pdfkit in Node.js without trouble so far, but my Electron application will not run after I add the import.
Code sample
import PDFDocument from 'pdfkit';
I receive the following error:
at createError (electron/js2c/asar.js:126)
at Object.fs.readFileSync (electron/js2c/asar.js:545)
at Object../node_modules/fontkit/index.js (ArabicShaper.js:5)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Module../node_modules/pdfkit/js/pdfkit.es5.js (index.js:20)
at __webpack_require__ (bootstrap:789)
at fn (bootstrap:100)
at Module../src/renderer/lib/exportToPdf.ts (exportToPdf.ts:3)
at __webpack_require__ (bootstrap:789)
Your environment
- pdfkit version: 0.11.0
- Electron version: 9.0.4
- Node version: 12.14.1
- Browser version (if applicable): Chromium 83.0.4103.104
- Operating System: Windows 10
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to use PDFkit library with webpack? - Stack Overflow
I've seen that many users are having issues with fs core module and webpack - and i tried every solution i could find....
Read more >PDFKit
PDFKit is a PDF document generation library for Node and the browser that makes creating complex, multi-page, printable documents easy.
Read more >Electron PDF SDK — Fast Setup, 100+ features - PSPDFKit
Integrate Electron PDF SDK to quickly deploy out-of-the-box features across macOS, Windows, Linux. Add PDF viewing, editing, form filling, ...
Read more >Generating PDF Files in Node.js with PDFKit - Stack Abuse
In this tutorial, we'll see how to generate PDF files in Node.js using PDFKit, how to customize them, align text, add images, scale...
Read more >How to include Node modules with Webpack
I had a similar problem in a project using Webpack, Electron, and Angular. ... You tried to require a Node module instead of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you try pdfkit-next?
It load resources in a browser friendly way. ( Not sure about electron )
There’s a webpack 5 example at https://github.com/foliojs/pdfkit/tree/master/examples/webpack. It should work with electron