Ok, I finally figured it out. After the update to the original question, I was still getting some errors with PDF files larger than 1MB. Chrome would not display the files and IE(compatibility mode) would corrupt them. I did not test it in firefox before finding a solution. My final script looks like this:
header('Content-type: application/pdf');
header('Content-Disposition: inline; filename="' . $file . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($path));
header('Accept-Ranges: none');
ob_clean();
flush();
readfile($path);
Note that $file is the name of the file (i.e. filename.pdf) and $path is the path to the file (i.e. C:/path/to/file/filename.pdf). To the original question, I added ob_clean();
and flush();
before the readfile call, and I set the 'Accept-Ranges' header to 'none'.
PDF file is now viewable in chrome and IE (compatibility mode). In firefox, the file actually downloads, but I am not too worried about that.
Similar question and answer found here: PHP stream PDF with fread and readfile produce a damaged pdf