PDF in php

Adobe’s Portable Document Format (PDF) provides a popular way to get a consistent look, both on screen and when printed, for documents

Dynamic construction of PDF files opens the door to many applications. You can create almost any kind of business document, including form letters, invoices, and receipts. Most paperwork that involves filling out a paper form can be automated by overlaying text onto a scan of the paper form and saving the result as a PDF file

PDF Extensions in php

PHP has several libraries for generating PDF documents. This chapter shows how to use the popular FPDF library. The FPDF library is a set of PHP code you include in your scripts with the require function, so it doesn’t require any server-side configuration or support, meaning you can use it even without support from your host

There is another PDF-generating library called TCPDF that is better at handling HTML special characters and UTF-8 multilanguage output. Look this up if you have that kind of a need. The methods you will be spending time with will be writeHTMLCell and writeHTML

Documents and Pages in php

A PDF document is made up of a number of pages. Each page contains text and/or images. This section shows you how to make a document, create pages in that document, put text onto the pages, and send the pages back to the browser when you’re done

A Simple Example of pdf in php

“Hello Out There!” in PDF

<?php
require("../fpdf/fpdf.php"); // path to fpdf.php
$pdf = new FPDF();
$pdf->addPage();
$pdf->setFont("Arial", 'B', 16);
$pdf->cell(40, 10, "Hello Out There!");
$pdf->output();
?>
 PDF example
PDF example

Leave a Comment