PHP Classes

SQL 2 PDF Report: Generate PDF documents from MySQL query results

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 43%Total: 7,798 All time: 226 This week: 102Up
Version License PHP version Categories
sql2pdfreport 1.0.1GNU General Publi...4Databases, Files and Folders, Web ser...


This class can be used to generate a PDF document from the results of MySQL database queries.

The class can execute one or more given queries and generate dump the results as HTML tables to a temporary page file.

The PDF document is generated by calling a remote Web service that fetches the generated HTML page and convert it to the PDF format.


What is the best PHP class to create PDF table from SQL results
Create query results table in PDF

What is the best PHP mysql to pdf class?
Export MySQL query results to pdf or excel

PHP page to PDF
Output PHP page to pdf

What is the best PHP print to pdf class?
I want to generate PDF print outs from a MySQL application

Picture of Rupom Razzaque
  Performance   Level  
Name: Rupom Razzaque is available for providing paid consulting. Contact Rupom Razzaque .
Classes: 12 packages by
Country: Bangladesh Bangladesh
Age: 42
All time rank: 171 in Bangladesh Bangladesh
Week rank: 198 Down5 in Bangladesh Bangladesh Down
Innovation award
Innovation award
Nominee: 1x

Winner: 1x


* SQL2PDFReport Generator Class
* @author : MA Razzaque Rupom <>, <>
* Moderator, phpResource Group(
* URL:
* @version : 1.0
* @date 06/05/2006 (modified on 06/23/2006)
* Purpose : Generating Pdf Report from SQL Query


//make sure the DB connection is ok

//queries whose output will be used as report data
$query_1 = "SELECT * FROM book";
$query_2 = "SELECT title,author FROM book";
$query_3 = "SELECT book_id,publisher,reader FROM book";

$obj = new Sql2PdfReport();

//sets absolute path where temporary report HTML file will be saved (should be under doc_root so that its URL can be set)
$obj->setHtmlPath("/projects/rupom/phpclasses/sql2pdfreport/first_test.html"); //change this according to your Path

//sets URL of the temporary report HTML file
$obj->setHtmlUrl("http://localhost/phpclasses/sql2pdfreport/first_test.html");//change this according to your URL

//inits row colors. colors will be repeated automatically

//generates report from $query_1

//changes row colors for the second report.

//generates report from $query_2 and appends it to previous report data

//generates report from $query_3 and appends it to previous report data

//pdf version
$pdfVersion = '1.4'; //change it according to your need
$pdfVersion = 1.3 for Acrobat Reader 4
$pdfVersion = 1.4 for Acrobat Reader 5
$pdfVersion = 1.5 for Acrobat Reader 6

//sets PDF version

//gets the pdf report of all the report data

  • screenshot.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file book.sql Data Example SQL File
Accessible without login Plain text file ReadMe.txt Data Documentation
Plain text file Sql2PdfReport.class.php Class Sql2PdfReport Class
Accessible without login Plain text file usage.php Example Example Usage

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:226
This week:102Up
User Ratings User Comments (1)
 All time
10 years ago (Leon Nguyen)