PDF Generation Results in ERR_INVALID_RESPONSE in Chrome
<p>When generating a PDF in the browser programmatically (via PHP) the rendered PDF displays fine in both Firefox and Safari, but Chrome returns an ERR_INVALID_RESPONSE. It is a valid PDF - can be opened locally with Adobe Reader/Preview once saved from the working browsers, and will even open in Chrome once the PDF is saved from a different browser.</p>

<p>The PDF file is being read through <code>file_get_contents()</code>, is given a current timestamp and then passed to the browser. A workaround would involve saving the file to a temporary spot and redirecting the user (for Chrome, at least) but this is not ideal.</p>

<p>I've researched it and only been able to find <a href="https://code.google.com/p/chromium/issues/detail?id=138" rel="nofollow noreferrer">bug reports dating from 2008</a>. </p>

<p>I have an inkling it's a header error. After the PDF is generated, the following headers are sent to the browser (again working fine in FF, Safari and IE):</p>

<pre><code>    header('Content-type:application/pdf');
    header("HTTP/1.1 200 OK");
</code></pre>

<p>I've also tried adding the following headers after searching on Stack Overflow, but to no avail:</p>

<pre><code>    header("Content-Transfer-Encoding: binary");
    header('Accept-Ranges: bytes');
</code></pre>

<p>Are there missing headers that Chrome requires? Does anyone have experience with getting dynamically generated PDFs to display in Chrome? </p>

<p>EDIT: One of my more salient questions is what could be causing this to work fine locally in Chrome, but wouldn't work on a server environment.</p>