php exp7 23
php exp7 23
Experiment No: 7
Title of Experiment Write a simple PHP program to create PDF document by using graphics
concepts.
Program Code:
<?php
require('fpdf.php');
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(60,10,'Hello PHP World!',1,1,'C');
$pdf->Output();
?>
The include statement includes the specified file and generates a warning if the
file is not found or if there is a problem including the file. If the included file is not
found, the script continues to run, but any code in the file that was not included
will be skipped.
The require statement, on the other hand, includes the specified file and
generates a fatal error if the file is not found or if there is a problem including the
file. If the included file is not found, the script will stop running immediately, and
any code after the require statement will not be executed.
2. State the use of Cell() function.
n PHP, the Cell() function is used in conjunction with the FPDF library to output text
in a cell of a PDF document.
The Cell() function is called on an instance of the FPDF class, and takes several
parameters:
• $width: The width of the cell in millimeters. If set to zero, the cell extends to the
right margin.
• $height: The height of the cell in millimeters. If not specified, the default value
of zero is used, which means the cell height will be calculated automatically
based on the content.
• $text: The text to be printed inside the cell.
The AddPage() method is called on an instance of the FPDF class, and takes no
parameters. It simply adds a new page to the PDF document and sets the cursor
position to the top left corner of the page.
The SetFont() method is called on an instance of the FPDF class, and takes three
parameters: