最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PDF.js Message : Unexpected server response (0) while retrieving PDF - Stack Overflow

programmeradmin1浏览0评论

I'm still fairly new to PDF.js. I'm trying to link my viewer.html with my pdf which are located in another server, eg: 100.0.55.10. Code shown below is how I embed the pdf in my iframe.

//LocalDir = http:///127.0.0.1/Main/Apps/Document/web
//BookLoc = http:///100.0.55.10/pdfFolder/pdfname.pdf

<iframe id="framePDF" name="framePDF" src="#LocalDir#/viewer.html?file=#BookLoc#" frameborder="0" height="500px" width="100%"></iframe>

I've managed to go around the issue with CORS by changing the mode in viewer.js to 'no-cors'. However, now it can't retrieved the pdf from the server 100.0.55.10.

I'm still fairly new to PDF.js. I'm trying to link my viewer.html with my pdf which are located in another server, eg: 100.0.55.10. Code shown below is how I embed the pdf in my iframe.

//LocalDir = http:///127.0.0.1/Main/Apps/Document/web
//BookLoc = http:///100.0.55.10/pdfFolder/pdfname.pdf

<iframe id="framePDF" name="framePDF" src="#LocalDir#/viewer.html?file=#BookLoc#" frameborder="0" height="500px" width="100%"></iframe>

I've managed to go around the issue with CORS by changing the mode in viewer.js to 'no-cors'. However, now it can't retrieved the pdf from the server 100.0.55.10.

Share Improve this question edited Jul 5, 2019 at 2:18 jdow asked Jul 4, 2019 at 8:36 jdowjdow 591 gold badge1 silver badge11 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 0

Have you tried the solution suggested here? It sounds like you might be able to resolve it with additional CORS configuration: https://github./mozilla/pdf.js/issues/4530

There's some good information in the FAQ for PDF.js: https://github./mozilla/pdf.js/wiki/Frequently-Asked-Questions#faq-xhr

发布评论

评论列表(0)

  1. 暂无评论