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

Recommended Answers

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

Jump to Post

All 2 Replies

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)

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.)

class PDF extends PDF_CLASS
// Page header
function Header()
//Arial bold 15
//Move to the right
//Line break

// Page footer
function Footer()

// Position at 1.5 cm from bottom
// Arial italic 8
// Page number
$this->Cell(0,10,"Subject Code: $this->subject");
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R');
$this->Cell(10,10,'test footer');

$pdf = new PDF();

  1. dashboard.php (this is the dashboard)

<meta charset="utf-8">
<title>Print pdf</title>

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

Be a part of the DaniWeb community

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