FPDF ouput () saves html file

I am saving a PDF document using FPDF using the following code ...

$pdf->Output('doc.pdf','D');

... but he saves it as "doc.pdf.html"

Why does he add the html extension?

+3
source share
2 answers

The problem for this in my case was that I did not finish the script immediately after I released the PDF file. I used the framework and let it finish, which caused the problem. So just add the "exit" statement, and it should fix it.

+11
source

It does not add the .html extension:

source:

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;

therefore the problem should be somewhere else.

0
source

Source: https://habr.com/ru/post/1775925/


All Articles