FranckFreiburger / vue-pdf

vue.js pdf viewer
MIT License
2.18k stars 519 forks source link

vue-pdf 4.0.6 library not work properly with vuejs version 2. #149

Open deepenpatel19 opened 5 years ago

deepenpatel19 commented 5 years ago

I followed your examples and successfully run in local environment except production and development server. I'm not able to preview of pdf file on those servers.

I tried two ways to preview pdf files and as listed below. First, this.imageFileURL = URL.createObjectURL(imageFileObject) and second this.imageFileURL = pdf.createLoadingTask(URL.createObjectURL(imageFileObject)). here, imageFileObject variable provide file object from input method of javascript.

In addition, I would like to add how I imported library and register component. how I import is, import pdf from 'vue-pdf' then register component like, pdf: pdf,

jpbferreira commented 5 years ago

Did you get any progress on this issue? I'm having the same trouble running in production server, but can't figure it out.

jpbferreira commented 5 years ago

@deepenpatel19 we managed to get it to work. There is a file called '(hash).worker.js' that wasn't being downloaded during the requests due to permission restriction we configured in SpringBoot. It looks like this file has some settings used by vue-pdf. I Hope it can help you in some way.

deepenpatel19 commented 5 years ago

@jpbferreira Thanks for information.

I tried to find #.worker.js. but, no luck. I found something like var PdfjsWorker = require('worker-loader!pdfjs-dist/build/pdf.worker.js'); under vuePdfNoSss.vue and vuePdfSss.vue. Could you give me more information for how you managed?

ghost commented 4 years ago

Not sure if this would solve, but I encountered a similar problem elsewhere with web workers, which are used by the core layer of the underlying PDF.js library.

Assuming you're using webpack, loading worker files requires:

module.exports = {
    configureWebpack: { 
        output: { 
            globalObject: 'this', 
        }, 
    },
}
FMagnanWD commented 4 years ago

Hi, I have same issue ... Have you solved this issue ? When my app was compiled, I've no fetch request to get PDF preview but in local dev, 'fetch" method was sent.

Thanks