Hi, I used fpdf lib to print pdf. And I want my php class be integrate in fpdf?
Can anyone help me?

Can you explain with a small code sample what you mean ?

I have dashboard.php and inside the teacher's dashboard I have print pdf link.
the purpose of the "print pdf" is to generate all the questionaires.
I have class_pdf which contains of all the functions to retrieve data from my db.

  1. class_pdf.php (this is my php class that call data from my database)
    require_once('../connection.php');
    require('fpdf.php');

class PDF_CLASS extends FPDF

function get_worksheet_title($worksheet_id)

$data = array();
$sql = mysql_query("SELECT worksheet_id, worksheet_title, description FROM worksheet_text ORDER BY worksheet_title ASC");
while ($row = mysql_fetch_array($sql))
$data[] = $row;

return $data;

function get_question_text($question_id)
$data = array();
$sql = mysql_query("SELECT question_id, question_text, description FROM question_text ORDER BY question_text ASC");
while ($row = mysql_fetch_array($sql))
$data[] = $row;

return $data;

  1. print_pdf.php (This is the pdf that need to generate pdf. I dont know how to print the data into pdf. please help.)
    require('pdf_class.php');

class PDF extends PDF_CLASS
// Page header
function Header()
if($this->PageNo()==1)
//Logo
$this->Image('header.jpg',5,6,200);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Move to the right
$this->Cell(80);
//Title
//$this->Cell(30,10,'Title',1,0,'C');
//Line break
$this->Ln(45);
parent::Header();

// Page footer
function Footer()

// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,"Subject Code: $this->subject");
$this->Image('footer.png',0,281,210);
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R');
$this->SetY(-15);
$this->SetX(-125);
$this->Cell(10,10,'test footer');

$pdf = new PDF();
$pdf->Output();

  1. dashboard.php (this is the dashboard)

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Print pdf</title>
</head>

<body>
<a href="print_pdf.php?id=<?php echo $worksheet_id;?>" target="_blank">Print Pdf</a>
</body>
</html>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.