master3w
master3w

Reputation: 71

How to create pdf using php

i want to create PDF file for my PHP web page it must be some button like create PDF then user click button PDF file must automatically generate my web page dynamic page it contain MySQL tables how i do it and there are any open source software for it ...

Upvotes: 0

Views: 7315

Answers (2)

Imanuel
Imanuel

Reputation: 3667

You can make PDFs with fpdf: http://fpdf.org/

<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

Upvotes: 1

bobthyasian
bobthyasian

Reputation: 943

Generate the PHP as you usually would but add the header

header("Content-Type: application/pdf");
header('Content-Disposition:inline; filename="testing.pdf"'); //view in browser

Or

 header("Content-Type: application/pdf");
 header('Content-Disposition:attachment; filename="testing.pdf"'); //force download

Upvotes: 0

Related Questions