We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,620 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

fpdf library problem to implement from php class

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

2
Contributors
2
Replies
4 Hours
Discussion Span
9 Months Ago
Last Updated
4
Views
george.badole
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

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

pritaeas
Posting Prodigy
Moderator
9,547 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,496
Skill Endorsements: 98

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>

george.badole
Newbie Poster
2 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0774 seconds using 2.68MB