使用pdf.js在外部URL上加载pdf [英] Load pdf on foreign url with pdf.js

查看:1322
本文介绍了使用pdf.js在外部URL上加载pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将pdf从另一台服务器加载到我服务器中的pdf.js查看器。我收到错误
PDF.js v1.4.20(build:b15f335)
消息:文件来源与查看者不匹配

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"

我已经检查了很多答案,其中许多人说通过代理传递pdf网址,如: - link

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

搜索了很多我之后发现他们发布了一个新的补丁,他们已经锁定了任何CDR请求,如果我错了就纠正我: - 这是链接

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

我尝试了所有方法,但无法在我的服务器上启用CDR方法不起作用。

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

请帮我解决这个问题。
我的基本想法是在我的pdf阅读器上显示pdf(托管在第三方服务器上)(我是从pdf.js创建的)。

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).

推荐答案

我通过在viewer.js中注释这一行解决了这个问题。

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

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

并使用这样的代理。
http:/ /192.168.0.101/web/viewer.html?file=https://cors-anywhere.herokuapp.com/pathofpdf.pdf

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

这篇关于使用pdf.js在外部URL上加载pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆