ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

How to create a pdf file in code igniter?

user-image
تم إضافة السؤال من قبل Jargam Abbas Sayyed Mohammad Azam , Senior Software Developer , Trimax Infrastructure Ltd.
تاريخ النشر: 2013/12/21
islam khalil
من قبل islam khalil , Technical Manager , iCloudit

Please check this ...

http://www.phpclasses.org/package/2905-PHP-Convert-HTML-to-PDF-using-Web-services.html

عبدالرزاق رحمون
من قبل عبدالرزاق رحمون , IT engineer , Ministry of Education

u can use JASPER REPORT Jaspersoft

u can Use DOMPDF

u can use TCPDF

u can use mPDF

i thik that is the best try it

Julfkar  Moh Umar
من قبل Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited

Create one PHP helper file in “application/helpers/” directory of codeigniter, say “pdf_helper.php”, then copy below given code and paste it in helper file

Helper: application/helpers/pdf_helper.php

function tcpdf(){ require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php');}

Then in controller file call the above helper, suppose our controller file is “createpdf.php” and it has method as pdf(), so the method pdf() will load the “pdf_helper” helper and will also have any other code.

Controller: application/controllers/createpdf.php

function pdf(){ $this->load->helper('pdf_helper');/* ---- ---- ---- ---- your code here ---- ---- ---- ---- */ $this->load->view('pdfreport', $data);}

Now create one view file, say “pdfreport.php” in “application/views/” directory, which is also loaded in pdf() method in controller. So in view file we can directly call the tcpdf() function which we have defined in “pdf_helper” helper, which will load all required TCPDF classes, functions, variable etc. Then we can directly use the TCPDF example codes as it is in our current controller or view. Now in out current view “pdfreport” copy the given code below:

View: application/views/pdfreport.php

tcpdf(); $obj_pdf =new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT,true,'UTF-8',false); $obj_pdf->SetCreator(PDF_CREATOR); $title ="PDF Report"; $obj_pdf->SetTitle($title); $obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING); $obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN,'', PDF_FONT_SIZE_MAIN)); $obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA,'', PDF_FONT_SIZE_DATA)); $obj_pdf->SetDefaultMonospacedFont('helvetica'); $obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER); $obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER); $obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT); $obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); $obj_pdf->SetFont('helvetica','',9); $obj_pdf->setFontSubsetting(false); $obj_pdf->AddPage(); ob_start();// we can have any view part here like HTML, PHP etc $content = ob_get_contents(); ob_end_clean(); $obj_pdf->writeHTML($content,true,false,true,false,''); $obj_pdf->Output('output.pdf','I');

Mustafeez Aslam
من قبل Mustafeez Aslam , Senior Software Engineer / Full Stack Developer , Paytabs.com

I have used HTML2PDF so many times and its really very simlple and flexible.

Umair Majeed
من قبل Umair Majeed , Software Engineer , Fbombmedia LLC

use this libarary for CI this is lite weight. 

 

http://www.tcpdf.org/

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟