pdf2json
pdf2json copied to clipboard
Running on Electron "Uncaught Error: No PDFJS.workerSrc specified"
For some reason when I run pdf2json on my electron app I get "Uncaught Error: No PDFJS.workerSrc specified".
FYI: I tried setting workerSrc to pdf.worker.js but that won't solve it. It just brings up another error,
@modesty
how did you run pdf2json? if you run it via cmd line, or as a web service, this error should not occur.
@modesty I ran in an electron app.
pdj2json is designed to run outside browser, and never tested with embedded browser (as in electron framework). 3 options here:
- invoke cmd line to run pdf2json from your app
- set globalScope.PDFJS.disableWorker to be true
- set PDFJS.workerSrc = Worker
@whitef0x0 @modesty It turns out that I have the same problem too. Any luck on running pdf2json in electron? Thanks...
It works when you run it in the main process and not in any of the rendering process, and use the remote api to exchange data between them.
@lanwin Thanks for your heads up. That works for me too...
It should be possible to require it in a rendering process by: require('electron').remote.require(...)
@parzel Thanks for the explanation. I used it that way too...
using
let PDFParser = require('electron').remote.require('pdf2json')
instead of
let PDFParser = require('pdf2json')
worked for me. Thank you!
@suparpat - can you please tell, what should I do to get the same PDFParser object in nwjs
app?
I'm getting the same issue, most probably it'll be the same solution.
However, I'm unable to load pdf2json
module correctly in nwjs
app.
It worked for me during development with electron:serve, after bundling the program with electron:build, opening the executable would cause the module not being found.
I did the correct way and moved my code to the main proccess.