pdf.js default viewer doesn't show pdf file

和自甴很熟 提交于 2021-01-29 05:41:44

问题


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">

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

It works fine to direct download the pdf file by typing https://myserver.tld/generator.php?id=1 in the browser.

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

But the prestyled viewer.html just returns

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

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


回答1:


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



来源:https://stackoverflow.com/questions/56733571/pdf-js-default-viewer-doesnt-show-pdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!