14
02Export invoice in html page to pdf using codeigniter
In this tutorial, we are going to download the invoice in pdf using codeigniter. Html to pdf is one of the challenging tasks for every programmers. There are many api and library are been used by the programmer to exort the data in pdf format.Finally I found easy method to convert html page into pdf.There are many library files been found to convert html to pdf. Some of them are FPDF,TCPDF,mPDF, DOMPDF etc. Here we are using TCPDF to convert the html data into pdf format. TCPDF is an opersource phplibrary and very useful for the developers.
Controller
load->helper('pdf_helper'); $this->load->view('pdfreport', $data); } } ?>
Views
SetCreator(PDF_CREATOR); $title = "Hack and PHP"; $obj_pdf->SetTitle($title); $obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, "Commercial Invoice"); $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(); ?>
By Thirumani Raj posted on - 14th Feb 2016
Social Oauth Login
Personalized Map Navigation
Online Image Compression Tool
Image CompressionAdvertisement
Recent Posts
- « Personalized Map Navigation
- « Remjs solves the problem of mobile terminal adaptation
- « Picture centered vertically
- « Colorful Diwali Wishes Share Via Whatsapp and Facebook
- « Get City and State by ZipCode Using Google Map Geocoding API