FPDF ouput() saves file with html extension
I'm saving a PDF document with FPDF using the following code...
$pdf->Output('doc.pdf','D');
...but it saves it as 'doc.pdf.html开发者_C百科'
Why is it adding the html extension?
The problem for this in my case, was that I was not terminating the script right after I echo'd out the PDF. I was using a framework and letting it finish out which was causing the problem. So just add an "exit" statement and it should fix it.
It does not add a '.html' extension:
source code:
case 'D':
//Download file
if(ob_get_length())
$this->Error('Some data has already been output, can\'t send PDF file');
header('Content-Type: application/x-download');
if(headers_sent())
$this->Error('Some data has already been output, can\'t send PDF file');
header('Content-Length: '.strlen($this->buffer));
header('Content-Disposition: attachment; filename="'.$name.'"');
header('Cache-Control: private, max-age=0, must-revalidate');
header('Pragma: public');
ini_set('zlib.output_compression','0');
echo $this->buffer;
break;
so the problem must be somewhere else.
精彩评论