问题
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