Create PDF report from php

I am using PHP code to query the database, and the results will be used to create the report.

If I want the report to be generated in pdf format, how do I do it?

+7
php pdf
source share
4 answers

If you need UTF support in your PDF file, tcpdf library.

Download it here: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

And in your script:

 <?php //include files require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/config/lang/eng.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/tcpdf.php'); // create new PDF document $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); //add some content using class methods //Close and output PDF document $pdf->Output('filename.pdf', 'I'); ?> 
+11
source share

Check out html2pdf

Create your report as html and then run the code to convert to PDF. You do not need to know the language for creating PDF blocks. Presented forms also look cool.

+2
source share

You can also use FPDF , I used this for several projects. In the beginning it will be very annoying, but when you get used to it, it will be easier for you to create pdf :)

+1
source share

I used TCPDF ( http://www.tcpdf.org/ ) for my last project. This worked fine, but the next time I am going to convert html to pdf, simply because creating the report (converting to pdf output applications) was such a time.

So, I would suggest http://sourceforge.net/projects/html2fpdf/

+1
source share

All Articles