• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to export gridview data to pdf file in php using Codeigniter

#1
[eluser]naveen27[/eluser]
Hi Everyone,
I am new to the Codeigniter,how to export gridview data to pdf file in php using Codeigniter. I am using MPDF library and it placed in systen/helper.i created one file in the same folder
i.e
pdfexport_helper.php
Code:
<?php
if ( ! function_exists('exportMeAsMPDF'))
{
            function exportMeAsMPDF($htmView,$fileName) {

                        $CI =& get_instance();
                        $CI->load->library('MPDF54/mpdf.php');
                       // $CI->mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
                        $CI->mpdf->AliasNbPages('[pagetotal]');
                        $CI->mpdf->SetHTMLHeader('{PAGENO}/{nb}', '1',true);
                        $CI->mpdf->SetDisplayMode('fullpage');
                        $CI->mpdf->pagenumPrefix = 'Page number ';
                        $CI->mpdf->pagenumSuffix = ' - ';
                        $CII->mpdf->nbpgPrefix = ' out of ';
                        $CI->mpdf->nbpgSuffix = ' pages';
                        $CI->mpdf->SetHeader('{PAGENO}{nbpg}');
                        $CI->mpdf = new mPDF('', 'A4', 0, '', 12, 12, 10, 10, 5, 5);
                        $style = base_url().'/source/template/css/stylesheet.css';
                        $stylesheet = file_get_contents( $style);
                        $CI->mpdf->WriteHTML($stylesheet,1);                      
                        $CI->mpdf->WriteHTML($htmView,2);                      
                        $CI->mpdf->Output('mpdf.pdf','I');
            }
}
My contrller is site.php
Code:
function pdf()
{
  $this->load->helper('pdfexport_helper.php');
  $urlid  = $this->uri->segment('3');
         if($urlid == "export")
   {

             $data['pageTitle'] = "Annual Report";
             $data['htmView'] = $this->load->view('site_view',$data,TRUE);
             $templateView  = $this->load->view('../template_export',$data,TRUE);
             exportMeAsMPDF($templateView,$data['filename']);    
                                                                            
        }
}
when i am click the Export to PDF it showing empty page.
Can anyone help me.
Thanks in advance.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.