Search Posts

I’m using angular-pdf-viewer for PDF Preview but using PDFJS.getDocument gives no-cors error. How to fix this?

I’m using this library on my Ionic Project https://github.com/winkerVSbecks/angular-pdf-viewer

And I’ve used this code to load a document

PDFJS.getDocument('http://localhost/books/book.pdf').then(function(pdf_doc) {
    console.log(pdf_doc);
});

But I’m getting this error whent trying to load a pdf document in Ionic V1. How can I solve this

Fetch API cannot load http://localhost/books/book1.pdf. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
    bluebird.min.js:29 Unhandled rejection Error: Failed to execute 'postMessage' on 'Worker': TypeError: Failed to fetch could not be cloned.
        at MessageHandler.postMessage (http://localhost:8100/js/pdf.js:1393:19)

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *