Documents and Pages
A PDF document is made up of a number of pages. Each page
contains text and/or images.Put text onto
the pages, and send the pages back
to the browser when you're done.
<?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( );
?>
follows the basic steps involved in creating a PDF document.
The cell concept in the FPDF Library is that of a rectangular
area on the page that you can create and control.
This cell can have a height,
width, a border, and of course can contain text.
The basic syntax for the
cell method is as follows:
Cell(float w [, float h [, string txt [, mixed border [, int ln [,
string align [, int fill [, mixed link]]]]]]])
The first option is the width, then the height, then the text
to be outputted, then border, then new line control, then its alignment, any
fill colour for the text, and finally if you want the text to be an HTML link.
So, for example, if we want to change our original example to have a border and
be center
aligned we would change the cell code to the following:
$pdf->Cell(90,10,'Hello Out There!',1,0,'C');
The cell method is used extensively while generating
PDF documents with fpdf,
Demonstrating coordinates and line management
<?php
require("../fpdf/fpdf.php");
$pdf = new FPDF('P', 'in', 'Letter');
$pdf->AddPage( );
$pdf->SetFont('Arial','B',24);
// Cell(W, H, 'text', Border, Return, 'Allign') - basic syntax
$pdf->Cell(0,0,'Top Left!',0,1,'L');
$pdf->Cell(6,0.5,'Top Right!',1,0,'R');
$pdf->ln(4.5);
$pdf->Cell(0,0,'This is the middle!',0,0,'C');
$pdf->ln(5.3);
$pdf->Cell(0,0,'Bottom Left!',0,0,'L');
$pdf->Cell(0,0,'Bottom Right!',0,0,'R');
$pdf->Output( );
?>
|