0% found this document useful (0 votes)
2 views

php exp7 23

The document outlines a laboratory experiment for web page development using PHP, specifically focusing on creating a PDF document with graphics concepts. It includes a sample PHP program using the FPDF library and practical questions regarding PHP functions like include, require, Cell(), AddPage(), and SetFont(). Additionally, it provides exercises for setting up headers and footers in PDFs and using color functions in PDF generation.

Uploaded by

aafu202
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)
2 views

php exp7 23

The document outlines a laboratory experiment for web page development using PHP, specifically focusing on creating a PDF document with graphics concepts. It includes a sample PHP program using the FPDF library and practical questions regarding PHP functions like include, require, Cell(), AddPage(), and SetFont(). Additionally, it provides exercises for setting up headers and footers in PDFs and using color functions in PDF generation.

Uploaded by

aafu202
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/ 3

DEPARTMENT OF COMPUTER ENGINEERING

Subject: web page development using php Subject Code: 22619


Semester: 6 Course: CO6I-A
Laboratory No: Name of Subject Teacher: Saqib Ghatte
Name of Student: AFIF IRFAN NAZIR Roll Id: 21203A1005

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();
?>

Practical related questions.


1. What is the difference between include and require?
In PHP, both include and require statements are used to include code from
another file into the current file, but they differ in how they handle errors.

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.

3. State the use of AddPage()


In PHP, the AddPage() method is used in conjunction with the FPDF library to add a
new page to a PDF document.

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.

4. State the use of setFont().


In PHP, the SetFont() method is used in conjunction with the FPDF library to set the
font style and size for text output in a PDF document.

The SetFont() method is called on an instance of the FPDF class, and takes three
parameters:

• $family: the font family to use (e.g. "Arial", "Times", "Courier")


• $style: the font style to use (e.g. "B" for bold, "I" for italic, "U" for underline)
• $size: the font size to use (in points)
Exercise
1. Write a script for setup Header and Footer along with line break and generate
a pdf.

2. Write a code based on setFillcolor() and setTextColor() and generate a pdf.

You might also like