pdf.js默认查看器不显示pdf文件 [英] pdf.js default viewer doesn't show pdf file

查看:458
本文介绍了pdf.js默认查看器不显示pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用具有建议的默认设置的pdf.js库:

I'm using pdf.js library with the recommended default settings:

<iframe src="https://myserver.tld/lib/pdf.js/web/viewer.html?file=https://myserver.tld/generator.php?id=1" width="800px" height="600px">

因此,基本上,我使用pdf.js的自托管版本,并希望默认查看器显示由php脚本生成的pdf文件(

So basicly I use a self-hosted verion of pdf.js and want the default viewer to display a pdf file which is generated by a php-script (https://myserver.tld/generator.php?id=1).

通过键入 https://myserver.tld/直接下载pdf文件,效果很好generator.php?id = 1 在浏览器中.

使用此示例: https://mozilla.github.io/pdf.js/examples/并使用canvas元素呈现页面也可以正常工作.

Using this example: https://mozilla.github.io/pdf.js/examples/ and rendering the page with a canvas element also works fine.

但是预先设置样式的viewer.html会返回

But the prestyled viewer.html just returns

PDF.js Version 2.0.943 (build: dc98bf76)
Nachricht: Invalid PDF structure

有人知道如何解决此问题,或者可以提供在浏览器中运行的良好的,具有预样式的pdf查看器吗?我不想自己设置所有按钮,功能等的样式.谢谢

Does anybody know how to fix this issue or can provide a good, prestyled pdf viewer running in the browser? I dont want to style all the buttons, function etc on my own. Thank you

推荐答案

我最终通过将URL作为参数将pdf文件保存在一个临时位置.那行得通.

I finally ended up saving the pdf file in a temporary location at giving this url as a parameter. That works.

这篇关于pdf.js默认查看器不显示pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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