0% found this document useful (0 votes)
35 views1 page

PHP Practical Nunber 7th

The document is a PHP script that utilizes the FPDF library to create a sample PDF. It demonstrates how to add a title, content, and line breaks, as well as how to output the PDF either as a file or to the browser. The script serves as a basic example of programmatically generating PDFs with PHP.

Uploaded by

patelprit2910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

PHP Practical Nunber 7th

The document is a PHP script that utilizes the FPDF library to create a sample PDF. It demonstrates how to add a title, content, and line breaks, as well as how to output the PDF either as a file or to the browser. The script serves as a basic example of programmatically generating PDFs with PHP.

Uploaded by

patelprit2910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

<?

php
// Include the FPDF library (make sure the fpdf.php file is in the same
directory or include the path)
require('fpdf/fpdf.php');

// Create a PDF object


$pdf = new FPDF();

// Add a page
$pdf->AddPage();

// Set font for the PDF (family, style, size)


$pdf->SetFont('Arial', 'B', 16);

// Add a title
$pdf->Cell(200, 10, 'Sample PDF Created with FPDF', 0, 1, 'C');

// Set a smaller font for the content


$pdf->SetFont('Arial', '', 12);

// Add some content to the PDF


$pdf->Ln(10); // Line break
$pdf->MultiCell(0, 10, 'This is a sample PDF created using the FPDF library in
PHP. You can add text, images, tables, and much more. This is just a simple
example of how to generate PDFs programmatically using PHP and FPDF.');

$pdf->Ln(10);
$pdf->Cell(200, 10, 'Another Line of Text Below.', 0, 1, 'L');

// Output the PDF (either as a file or to the browser)


$pdf->Output('F', 'example.pdf'); // 'F' indicates saving the file. Use 'I' to
display in browser.
?>

You might also like