Closed pixelpaulaus closed 3 years ago
I found the same problem a couple of minutes ago
I found the same problem a couple of minutes ago
I have been trying to figure it out for a while now, with no luck. If you make any progress on it, please let me know.
For what it worth, if I manually copy the file node_modules/pdfjs-dist/build/pdf.worker.js into my dist folder and name it 11.worker.js it works.
This is not a workaround, iti's just a piece of information for someone who can help us solve the problem.
this is so anoying. i am about to move to another vue pdf viewer, uneless anyone can assist? @arkokoley
Do you need to update to the latest version because of a bug?
correct. older versions of this were not working on certain platforms. so i upgraded, now none work :-(
@pixelpaulaus @joepsyko I'm working on this issue at the moment. I'll release a working version by today.
ok, so I understand your frustration
Hi @arkokoley , do you need any help with anything? happy to help if i can
Same problem with me.
can anyone recommend another pdf package for vue that works well?
@pixelpaulaus you could give https://www.npmjs.com/package/vue-pdf a try.
This fix should be as simple as adding:
const PdfjsWorker = require('worker-loader?esModule=false!pdfjs-dist/build/pdf.worker.js');
if (typeof window !== 'undefined' && 'Worker' in window) {
pdfjsLib.GlobalWorkerOptions.workerPort = new PdfjsWorker();
}
At the top of Pdfvuer.vue
after the imports. You'll need to add worker-loader
as a dependency.
I had to revert to 1.6.1
to be able to use this component.
Is this still being maintained/managed?
@pixelpaulaus you could give https://www.npmjs.com/package/vue-pdf a try.
vue-pdf does not have the text layer working out-of-the-box :(
Had to downgrade to 1.6.1
too.
Fix for this:
add worker-loader
npm i --save worker-loader
Add this to your webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.worker\.js$/,
use: {
loader: 'worker-loader',
options: {
filename: '[name].worker.js'
}
}
},
...
]
UPDATE:
Also add this to your App.vue
or main.js
/* eslint-disable */
var pdfwoker = require('worker-loader!pdfjs-dist/build/pdf.worker')
/* eslint-enable */
Hi,
we tried adding this into our webpack (vue.config.js), but we still get the 572.worker.js (<-- random number) is missing, we installed worker-loader via yarn and added it to both, webpackConfig and also tried it to add it to webchain, but neither of those changed the error. Are we missing something, or do you have another idea why it is not working for us?
Upgrading to 1.7.3 and I can't even load any PDFs in development mode.
Uncaught (in promise) Error: Setting up fake worker failed: "Cannot load script at: http://localhost:8080/app.worker.js"
I'm not sure how I am meant to bind app.worker.js.
I installed worker-loader and updated my Webpack settings as described ^
@nicholaszuccarelli, @TehEbil
filename: 'app.worker.js' // <---- Change the "[name]" to "app" or whatever it is that your script asks for.
@arkokoley thank you for your answer, but it changes after every build for us, do you have an advise?
This is the same with me too. My worker file changes every time.
Does someone have another idea?
@TehEbil @nicholaszuccarelli Add this to your App.vue
or main.js
/* eslint-disable */
var pdfwoker = require('worker-loader!pdfjs-dist/build/pdf.worker')
/* eslint-enable */
after upgrading to the latest version 1.7.1 It seems some files are no longer included when i build for production.
they seem to be files ending in
.worker.js
example... when using the module.. this file loads: invoices~quotes~sales.2a8b8dd7.js
when it is set to view a PDF this file loads: invoices~quotes~sales.2a8b8dd7.worker.js
but a 404 is returned, because the file was never built in production, and is also not available in development.
i am just using the latest vue-cli