-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross-Domain file ? #522
Comments
Hello, The PDF file is requested through a XMLHttpRequest so all the usual cross site scripting rules apply. There are a number of ways to get around this such as a proxy running on domainA see http://en.wikipedia.org/wiki/XMLHttpRequest#Cross-domain_requests for more options. Brendan |
Also, if the server at domainB sets the HTTP CORS headers properly (https://developer.mozilla.org/en/http_access_control#Access-Control-Allow-Origin) then the cross-origin request will work in modern browsers. |
Thank you very much for your explanations. I tried to set up and it works for the simple example, which use the ajax method var ajaxGet = function(url, callback){
}; However, in the advanced sample (like the web demo), it still didn't work. I think that the problem came from the function to call the file, it didn't support the binary type buffer. Could you guys to show me more ? I am no very good at javascript. Thank you again |
@infantiablue were you able to figure it out? |
How does the google doc viewer work around this problem?...probably a stupid question.. |
I'm not exactly sure but their doc viewer uses lots of server side processing so they don't have the same restrictions as a browser only program. |
Does anybody know if there is a way to use the client's connection. E.g. download the file to a temp directory (with any kind of script) and then load it with pdf.js? I guess thats not possible because of security issues, he? Would it be possible with a certificate or so? |
Hi I have the same issue ! I am uploading the pdf from one domain and displaying it in another domain. I am getting this error message PDF.JS Build: undefined How to solve this cross domian issue ? I tried to add to a server's HTTP response headers but does not work. Any help !! :( |
You need to allow Cross-origin Requests in the PDF hosting domain, so that it allows requests from the viewer domain. If you can't do that, then you can't do Cross-origin requests, because of security concerns. |
Here is how I solved this issue without changing pdf.js: http://colonelpanic.net/2014/08/using-pdf-js-web-worker-cross-domain-cors/ |
XMLHttpRequest cannot load http://www.cesp.com/my.pdf. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. ??? |
I have a list of PDF filenames, I want to load the corresponding PDF when clicking one of them.How can i do this with PDFJS? |
I have found the solution in asp.net c-sharp first convert cross domain pdf file into base64 string and then bind it into iframe. here is the solution : https://www.dontnetcodes.com/2021/03/How-to-Bind-a-cross-domain-pdf-file-into-pdf.js-viewer-pdf.viewer-issue-solution-in-asp.net-using-csharp.html |
Hi there,
Thank you for creating such an interesting open-source library. I am wondering if this support to call file cross domain. Such as, in the web view example, I set the kDefaultURL = http://domainB.com/file.pdf then I call that viewer.js from domainA.com and it didn't work.
Is there anyway to solve this issue ?
Thank you very much
The text was updated successfully, but these errors were encountered: