Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load pdf on foreign url with pdf.js

I am trying to load pdf from another server to the viewer of pdf.js in my server.I got error "PDF.js v1.4.20 (build: b15f335) Message: file origin does not match viewer's"

I already checked many answer, many of them said that pass the pdf url through a proxy like:- link

After searching a lot i found that they release a new patch in which they have lock down any CDR request, correct me if i am wrong:-Here is the link

but in their user manual they specified that it is possible here is the link

I tried all method but not able to enable CDR on my server and many methods didn't work.

Please help me to resolve this issue. My Basic idea is to show pdf(which is hosted on 3rd party server) on my pdf reader(that i made it from pdf.js).

like image 255
Mukesh Gupta Avatar asked May 22 '16 18:05

Mukesh Gupta


2 Answers

I resolved this issue by comment this lines in viewer.js

if (fileOrigin !== viewerOrigin) {
throw new Error('file origin does not match viewer\'s');
}

and use proxy like this. http://192.168.0.101/web/viewer.html?file=https://cors-anywhere.herokuapp.com/pathofpdf.pdf

like image 140
Mukesh Gupta Avatar answered Sep 20 '22 14:09

Mukesh Gupta


Add your domain/origin to HOSTED_VIEWER_ORIGINS array

like image 21
SANTHOSH.SJ Avatar answered Sep 20 '22 14:09

SANTHOSH.SJ