PDF file corrupted by download

Posted by editor

I use a download manger script to download pdfs. Recently one my sites pdf downloads started failing to work. When the pdf was loaded the system showed them to be corrupt.

Finally got the break I needed to fix this problem here ...

http://stackoverflow.com/questions/1418670/php-force-download-return-corrupted-file

Turns out, that the ending php tag was inserting a newline into the download stream of the pdf. I do not think this was fatal however as I have been using this script unchanged previously. So I removed the php end tag ( which of course in good php coding terms is unnecessary and even poor practice!). However, the real problem I suspect is that I had left debug echo's in the script, which was almost certainly the real problem. Everything started working just fine.

Hope this helps someone!