Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate PDF report from php

Tags:

php

pdf

I am using php code to query to a database and the results will be used to generate a report.

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

like image 790
Anand Sunderraman Avatar asked Mar 10 '10 13:03

Anand Sunderraman


1 Answers

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

Download it from 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');
?>
like image 194
Silver Light Avatar answered Sep 30 '22 13:09

Silver Light