jump to navigation

php pdf generate with dompdf and fpdf February 24, 2009

Posted by phpentertainer in Uncategorized.
Tags: , , , , ,
2 comments

Pdf Help

Report generatioin is a very important issue in every software. Specially for content management system or automation related project report generation is must. There are are several ways to generate report in php. Generally the better solution is to generate the reports as pdf format.
To generate pdf report in php normally dompdf and fpdf library is used. I have used both dompdf and fpdf to generate report in my some projects.

To use these library at first download the library from the following sites-
dompdf: http://www.digitaljunkies.ca/dompdf/usage.php

fpdf: http://fpdf.org

Here the manuals are enough to use these library in your project.
To marge two or more pdf into a single pdf then you should download the FPDI library from http://www.setasign.de/products/pdf-php-solutions/fpdi/demos/concatenate-fake/
To use fpdf in your project to create pdf report place the library in your root directory of your server. you can also place it in a folder or sub-folder in your root directory.
Now I shall explain the procedure to use this step by step.
1. If you want to parse a php variable into the pdf then perform the following steps.
a. in your html file (suppose pdf.html) the variables should write according to the following fashion-

BUYER’S NAME: /*name*/

b. now your php file (suppose action.php) where this variable will be parsed should be as follows

require_once(dirname(__FILE__).'/../html2pdf.class.php');
ob_start();
include(dirname('__FILE__').'/pdf_form.html');
$return = ob_get_clean();
if ( isset( $_POST["html"] ) ) {
if ( get_magic_quotes_gpc() )
$_POST["html"] = stripslashes($_POST["html"]);
$old_limit = ini_set("memory_limit", "32M");
if($_POST['empty_cell']== '')
$_POST['empty_cell'] = " ";
$return = str_replace("/*empty_cell*/", $_POST['empty_cell'], $return);
if($_POST['buyer']== '')
$_POST['buyer'] = " ";
$return = str_replace("/*name*/", $_POST['buyer'], $return);
$html2pdf = new HTML2PDF('P','A4','fr', array(0, 0, 0, 0));
$html2pdf->WriteHTML($return, isset($_GET['vuehtml']));
$html2pdf->Output('aaa.pdf');
}

c. the form action should be the above file (action.php).

Welcome February 24, 2009

Posted by phpentertainer in Uncategorized.
add a comment

Hi all,
Welcome to my blog. I am always here to give solution related to the recent web application technology.

Follow

Get every new post delivered to your Inbox.