WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Free PDF file creation using PHP.
Categories : PDF, PHP Click here to Update Your Picture
Srikanth Turaga
Date : Aug 09th 2003
Grade : 3 of 5 (graded 26 times)
Viewed : 48222
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Srikanth Turaga
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Hi friends,

I am posting the code of creating PDF files using PHP. You can use the PDF Lib that comes with the PHP, but then you have to pay them to create PDF files without their ads on them. Here is the code and links that would allow you to create your own PDF files without any ads on them and without paying a single cent to them.

The PDF lib is available at http://www.fpdf.org/. You can download the ZIP or TGZ files from this site and open them in any directory.

All you need to do is Define the font in your code and include the fpdf.php file into your code.

Below is a short code that helps you create a sample PDF file. Creating PDF file helps a lot in generating reports for the database transactions or creating downloadable question papers for online quizzes etc, etc.

This code works perfectly when I tested it.
Code follows:
HTML file to create PDF file.

<HTML>
<BODY>
<FORM method = "post" action ="pdfdemo.php">
<BR><INPUT TYPE=Submit name=Submit VALUE = "Create PDF">
</FORM>
</BODY>
</HTML>


PHP code that generates the PDF file.

<?php
define('FPDF_FONTPATH','/yourdirectorywhereFPDFisstored/FPDF/font/');
require('/yourdirectorywhereFPDFisstored/FPDF/fpdf.php');
class PDF extends FPDF
{
function DashedRect($x1,$y1,$x2,$y2,$width=1,$nb=15)
{
$this->SetLineWidth($width);
$longueur=abs($x1-$x2);
$hauteur=abs($y1-$y2);
if($longueur>$hauteur) {
$Pointilles=($longueur/$nb)/2; // length of dashes
}
else {
$Pointilles=($hauteur/$nb)/2;
}
for($i=$x1;$i<=$x2;$i+=$Pointilles+$Pointilles) {
for($j=$i;$j<=($i+$Pointilles);$j++) {
if($j<=($x2-1)) {
$this->Line($j,$y1,$j+1,$y1); // upper dashes
$this->Line($j,$y2,$j+1,$y2); // lower dashes
}
}
}
for($i=$y1;$i<=$y2;$i+=$Pointilles+$Pointilles) {
for($j=$i;$j<=($i+$Pointilles);$j++) {
if($j<=($y2-1)) {
$this->Line($x1,$j,$x1,$j+1); // left dashes
$this->Line($x2,$j,$x2,$j+1); // right dashes
}
}
}
}
}

$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
$pdf->SetDrawColor(200);
$pdf->DashedRect(20,10,190,40);
$pdf->SetFont('Arial','B',20);
$pdf->SetXY(40,10);
$pdf->Cell(125,30,'Congrats! You created your first PDF file.',0,0,'C',0);
$pdf->Output();
?>

You can find the tutorials and API references at http://www.fpdf.org/. If I remember my example
code is took from the tutorials posted at http://www.fpdf.org/.

Hope this helps some one. Please let me know if there is some problem with the code. I'll be glad
to help you.

Thank you,
Sri.



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
PDF class - This is a useful class to make a pdf file with php functions.
Categories : PHP, PDF, PHP Classes
How To Create a PDF Using PHP
Categories : PHP, PDF, PHP Classes, HTML and PHP
PHP-PDF-Converter
Categories : PHP, Excel, PDF, Microsoft Word, COM
Url To Pdf Report By Remote Application
Categories : PHP, PHP Classes, PDF, CURL
PDF_add_annotation -- Deprecitad: Adds annotation
Categories : PHP, PHP Functions, PDF
Generate FDF files without the pdftk library or php extension.
Categories : PHP, PHP Classes, PDF
function_exists -- Return true if the given function has been defined
Categories : PHP, PHP Functions, Functions
Functions used to define a schedule of holidays. Can define non-fixed holidays (eg. 3rd sunday of June).
Categories : Calendar, Date Time, PHP
Array Insertion
Categories : PHP, PHP Classes, Arrays
Is there any way to test that the $result has null values or not without reading the field values in the results in postgre?
Categories : PostgreSQL, PHP, Databases
crop and resize image class using gd library function
Categories : PHP, PHP Classes, GD image library, Graphics
Simple PHP Form Auto Generation based on MySQL query
Categories : PHP, Form Processing, Databases, MySQL, Sessions
Pageinfo: Array containing page URI, page query string (parameters), request method (GET or POST) and the complete URI
Categories : Variables, PHP Options and Info, Arrays, URLs, PHP
Classic guest book made with PHP and Flash
Categories : PHP, Flash, Java Script
 Marianne Mason wrote :1011
thank you.  This was a timely post as I`ve been given an assignment to upload documents and convert to pdf.