简体   繁体   中英

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();
?>

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM