simonheinrich
simonheinrich

Reputation: 91

pdf.js default viewer doesn't show pdf file

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

Upvotes: 0

Views: 2097

Answers (1)

simonheinrich
simonheinrich

Reputation: 91

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

Upvotes: 0

Related Questions