Search code examples
phpfpdf

Save PDF file as PDF not PHP


I am using using FPDF to create pdf file. But it show extension as php not pdf. When i download the file in mobile it show .php file. Now how can I convert the php extension to pdf

Here index.php file

 <a href="pdf.php">Click Here</a>

Here pdf.php file

 <?php
 require ("fpdf/fpdf.php");
 $name = "Amit Samadder";
 $pdf = new FPDF('p','mm','A4');
 $pdf->AddPage();
 $pdf->SetFont("Arial","B","20");
 $pdf->Cell(100,10, $name, 1,0, "C");
 $pdf->Output();
?>

Solution

  • Have a look at http://fpdf.org/en/doc/output.htm

    You need to change this line:

    $pdf->Output();
    

    To:

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