andreasgal/pdf.js — Issue #657: Invalid PDF structure if Content-Type: application/pdf
Author: lucaferrario
Created: 2011-10-12 10:10:17+00:00
State: open

Hi,
congratulations for this excellent project!
I'm a developer of another open-source project called oneye, and I'm integrating pdf.js into it.
I have a PHP that sends to the user the viewer.html file and all the JSs and CSS and sets the variable kDefaultURL to a value like "index.php?download=path.pdf". So the browser sends a request to the PHP script and the script sets the headers and sends to him the PDF file. But there is a very strange behaviour:
If the server sends the "Content-Type: application/pdf" header, I see the loading progress and when it gets to 100%, an "Invalid PDF structure" error is thrown and the file is not displayed. Otherwise, if I tell the PHP to send a Content-Type: text/html header even though the file is a PDF, the loading percent does not work (it remains at 0%), but the file is correctly loaded and displayed!
I don't know if this can be considered a pdf.js bug or else....please let me know if you need addictional testing!
Thank you very much!
Luca Ferrario