The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript automatic pdf download Reply To: automatic pdf download


Holler heard! ;)

I’m guessing that what may be causing issues is that you’re echoing HTML output before your header download code, and you can’t modify header information when headers have already been sent. If you turn PHP error reporting on, I suspect you’ll see errors outputted in the browser stating something along those lines.

So, what you should do is reorder your code so that the headers come before any HTML output (any of those echos, or other HTML that may be sat higher up the PHP file outside of PHP tags – including doctype), which, depending on your page, might be an easy refactoring job or it might be more complex.

On the other hand, you could try using ob_start(); at the very top of your PHP page. It isn’t ideal (and I’m likely to get stomped on for suggesting it), but its a workaround that may get you the results you’re after if you’re really in a bind.

But, turn error reporting on to check for the actual errors – they’re going to be the best indicators to help you troubleshoot.