Posts Tagged ‘pdf’
fpdf force save as not working
After finding out that I could not install a specific pdf creator on my shared hosting server, i decided to use the fpdf pdf creator. IT works well for what I need. But I could not get the dang save as dialog to appear. I fought with this for a few hours, and after searching and finding nothing. I went to the source of fdpf to find the answer.
It seems that with the most recent version of fpdf, the ouput function has changed slightly.
$pdf->output(“name.pdf”, “D”) ;
This doesn’t work anymore.
The way the function wants to work is with a boolean true / false for download or display inline.
So the way to force the download is to leave off the “D”, or “I” that you were used to in older versions.
To make the pdf display the “Save as” dialog box, you need to rewrite the output call like this.
$pdf->output(“name.pdf”);
Leave off the other attribute and voila it works.
It you still want to display it inline with the browsers defautl pdf reader, just add anything after the file name.
$pdf->output(“name.pdf”, true);
And it will open the pdf file in the browser window.
Hope this helps some folks out there.