Hello,
Sorry i want to ask about my issue, i already run with ionic serve and i try to open local pdf file, it can work properly, but after i try to check in www/ folder especially on index.html, just clicked it once, show in browser, but file is not loaded and show an error like this :
Fetch API cannot load file:///Users/toni/Documents/myApp/www/assets/files/test.pdf. URL scheme must be "http" or "https" for CORS request.
So can you help me to solve this issue ? thanks.
The problem with this is the version of PDFJS-dist that is being used. NPM seems to ignore the pdfjs-dist version in package.json and installs version 1.9.
A quick work around:
npm install [email protected] and check your __package.json__ for version _1.6.329_.
See method onFileSelected() - this is how you can load local pdfs
https://github.com/VadimDez/ng2-pdf-viewer/blob/master/src/app/app.component.ts#L52-L64
Im getting the same error.
I generate a pdf file and write it to the device dataDirectory , and get the same error trying to set the pdf Source. downgrading pdfjs-dist didnt help as well.
Hi
Remove the NPM package lock, node_modules and run npm install [email protected]. Hopefully that helps.
On Thu, Oct 19, 2017 at 4:44 PM +0100, "Yashrad" notifications@github.com wrote:
Im getting the same error.
I generate a pdf file and write it to the device dataDirectory , and get the same error trying to set the pdf Source. downgrading pdfjs-dist didnt help as well.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
Is there a solution for this issue ?
Im using ng2-pdf-viewer v5.0.1 and still getting this error:
"Fetch API cannot load file:///data/user/0/MY_APP/files/MY_FILE.pdf. URL scheme "file" is not supported.
My use case is try to view previously 'downloaded' pdfs on a ionic3 app
Tried other libs like pdfjs and no luck.
Any help would be appreciated
Thanks
Hi, How to resolve the problem ?
I get this message :
polyfills-es2015.js:5958 Access to XMLHttpRequest at 'file:///data/user/0/io.ionic.starter/www/doc/13.pdf' from origin 'http://localhost' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, https."``
This work with the file directly in asset folder and with the next url :
http://localhost:8000/assets/000000221394393_61908343.pdf
But I need to download the file and I can not download it in asset directory.
If your having issues it's because of a the new versions of PDFjs library supplied by Mozilla.
Try working with version 1.0.2: npm i [email protected] --save
Hopefully this will help.
Most helpful comment
See method
onFileSelected()- this is how you can load local pdfshttps://github.com/VadimDez/ng2-pdf-viewer/blob/master/src/app/app.component.ts#L52-L64