dompdf to mpdf

This commit is contained in:
gandhimathi 2017-12-01 17:23:24 +05:30
parent 13104a8c6f
commit 4ee5aab34c
7 changed files with 104 additions and 77 deletions

View File

@ -1,6 +1,7 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); <?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php'; require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/** /**
* Class : MRIRcontroller (Material Inspection Report - Controller) * Class : MRIRcontroller (Material Inspection Report - Controller)
@ -48,30 +49,31 @@ class MRIRcontroller extends BaseController
public function MrirDetailsPrintPdf() public function MrirDetailsPrintPdf()
{ {
$MrirNo = $_GET['MRIRNO']; $MrirNo = $_GET['MRIRNO'];
// echo $MrirNo;
$this->global['pageTitle'] = 'Resico : MRIR Pdf '; $this->global['pageTitle'] = 'Resico : MRIR Pdf ';
$data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation(); $data['CompanyDetails'] = $this->purchaseorder_model->getCompanyInformation();
//print_r($data['CompanyDetails']);
$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo); $data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
//$data['MRIRDetails'] = $this->mrir_model->edit_mrir($MrirNo);
//print_r($data['MRIRDetails']);
$this->load->View("Mrirprintpdf",$data, NULL); $this->load->View("Mrirprintpdf",$data, NULL);
//*********************MPDF***********
// Get output html
$php = $this->output->get_output(); $mpdf=new mPDF('utf-8','A4-P',8, 10,10, 10, 82, 38, 4, 6);
$mpdf->SetDisplayMode('fullpage');
// Load library $mpdf->SetHTMLHeader($HtmlHeading);
$this->load->library('dompdf_gen'); $html = $this->load->view('Mrirprintpdf',$data,true);
$mpdf->SetDisplayMode('fullpage');
// Convert to PDF $mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$this->dompdf->load_html($php); $mpdf->list_indent_first_level = 1;
$this->dompdf->render(); $mpdf->setAutoTopMargin = 'stretch';
$data['Attachment'] = FALSE; $mpdf->setAutoBottomMargin = 'stretch';
$this->dompdf->stream("MrirDetails.pdf",$data,$php); $mpdf->WriteHTML($html);
$mpdf->Output("MrirDetails".$data.'.pdf','I',$php);
} }

View File

@ -1,6 +1,8 @@
<?php if(!defined('BASEPATH')) exit('No direct script access allowed'); <?php if(!defined('BASEPATH')) exit('No direct script access allowed');
require APPPATH . '/libraries/BaseController.php'; require APPPATH . '/libraries/BaseController.php';
require APPPATH . '/third_party/mpdf/mpdf.php';
/** /**
* Class : payslip (Pay Slip - Controller) * Class : payslip (Pay Slip - Controller)
@ -60,7 +62,8 @@ function phpAlert($msg) {
$m = substr($payon,0,2); $m = substr($payon,0,2);
$y = substr($payon,3); $y = substr($payon,3);
$month = $monthsoptions[$m]."-".$y; $month = $monthsoptions[$m]."-".$y;
$excel = $this->input->post('excel'); $excel = $this->input->post('excel');
$HTML="";
//echo $excel; //echo $excel;
// if(empty($excel)) // if(empty($excel))
// { // {
@ -95,7 +98,7 @@ function phpAlert($msg) {
$data['Totalamtwords']=$totamtwords; $data['Totalamtwords']=$totamtwords;
$data['PayMonth']=$month; $data['PayMonth']=$month;
$filename = 'Bank Report for'.$payon.'pdf' ; $filename = 'Bank Report for'.$payon.'pdf' ;
$this->load->View("bankreportprint",$data); $HTML = $this->load->View("bankreportprint",$data,true);
} }
if($this->input->post('PF_Report')) if($this->input->post('PF_Report'))
{ {
@ -123,7 +126,7 @@ function phpAlert($msg) {
$data['Totalamtwords']=$totamtwords; $data['Totalamtwords']=$totamtwords;
if(empty($excel)){ if(empty($excel)){
$filename = 'PF Report for'.$payon.'pdf' ; $filename = 'PF Report for'.$payon.'pdf' ;
$this->load->View("pfreportprint",$data); $HTML = $this->load->View("pfreportprint",$data,true);
// echo "PDF PART 1"; // echo "PDF PART 1";
} }
else{ else{
@ -257,7 +260,7 @@ function phpAlert($msg) {
if(empty($excel)){ if(empty($excel)){
$filename = 'ESI Report for'.$payon.'pdf'; $filename = 'ESI Report for'.$payon.'pdf';
$this->load->View("esireportprint",$data); $HTML = $this->load->View("esireportprint",$data,true);
// echo "PDF PART 1"; // echo "PDF PART 1";
} }
else{ else{
@ -352,28 +355,41 @@ function phpAlert($msg) {
if(empty($excel)){ if(empty($excel)){
$php = $this->output->get_output(); // $php = $this->output->get_output();
// Load library // // Load library
$this->load->library('dompdf_gen'); // $this->load->library('dompdf_gen');
require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php'); // require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF(); // $dompdf = new DOMPDF();
$dompdf->set_paper('A4', 'portrait'); // $dompdf->set_paper('A4', 'portrait');
$dompdf->load_html($php); // $dompdf->load_html($php);
$dompdf->render(); // $dompdf->render();
// add the header // // add the header
$canvas = $dompdf->get_canvas(); // $canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold"); // $font = Font_Metrics::get_font("helvetica", "bold");
// the same call as in my previous example // // the same call as in my previous example
$canvas->page_text(72, 18,"", // $canvas->page_text(72, 18,"",
$font, 6, array(0,0,0)); // $font, 6, array(0,0,0));
$dompdf->stream($filename); // $dompdf->stream($filename);
//echo "PDF PART 2"; // //echo "PDF PART 2";
$mpdf=new mPDF('utf-8','A4-P',9, 12,12, 10, 82, 38, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
//$html = $this->load->view("bankreportprint",$data,true);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($HTML);
$mpdf->Output("".$filename.'.pdf','I',$php);
} }
} }
@ -797,7 +813,7 @@ function getEmployee()
$Data['amtinwords']=$totalsalaryinwords; $Data['amtinwords']=$totalsalaryinwords;
//$Data['Count'] = $i; //$Data['Count'] = $i;
$this->load->View("payslipgenerateprint", $Data ); $html.= $this->load->View("payslipgenerateprint", $Data ,true);
} }
@ -813,41 +829,52 @@ function getEmployee()
$totalsalaryinwords = $this->convertNumber(round($totalsalary)); $totalsalaryinwords = $this->convertNumber(round($totalsalary));
$Data['amtinwords']=$totalsalaryinwords; $Data['amtinwords']=$totalsalaryinwords;
$this->load->View("payslipgenerateprint", $Data ); $html = $this->load->View("payslipgenerateprint", $Data,true );
} }
$php = $this->output->get_output(); // $php = $this->output->get_output();
// Load library // // Load library
$this->load->library('dompdf_gen'); // $this->load->library('dompdf_gen');
if($All != '') // if($All != '')
{ // {
$filename = 'Payslip-'.$Payon.'.pdf' ; // $filename = 'Payslip-'.$Payon.'.pdf' ;
} // }
else // else
{ // {
$filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ; // $filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ;
} // }
require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php'); // require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
$dompdf = new DOMPDF(); // $dompdf = new DOMPDF();
$dompdf->set_paper('A4', 'portrait'); // $dompdf->set_paper('A4', 'portrait');
$dompdf->load_html($php); // $dompdf->load_html($php);
$dompdf->render(); // $dompdf->render();
// add the header // // add the header
$canvas = $dompdf->get_canvas(); // $canvas = $dompdf->get_canvas();
$font = Font_Metrics::get_font("helvetica", "bold"); // $font = Font_Metrics::get_font("helvetica", "bold");
// the same call as in my previous example // // the same call as in my previous example
$canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}", // $canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
$font, 6, array(0,0,0)); // $font, 6, array(0,0,0));
$dompdf->stream($filename); // $dompdf->stream($filename);
// }
$mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10, 10, 24, 4, 6);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($HtmlHeading);
$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
$mpdf->setFooter("Page {PAGENO} of {nb}");
$mpdf->list_indent_first_level = 1;
$mpdf->setAutoTopMargin = 'stretch';
$mpdf->setAutoBottomMargin = 'stretch';
$mpdf->WriteHTML($html);
$mpdf->Output("".$filename.'.pdf','I',$php);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -44,13 +44,13 @@ if(!empty($companyinfo))
</div> </div>
</div> </div>
</div> </div>
<div class="page" style="font-size:12px;"> <div class="page" style="font-size:12px;">
<p><strong>Employeer ESIC account No</strong>: <strong>TNAMB1556420000</strong></p> <p><strong>Employee EPFO account No</strong>: <strong>TNAMB1556420000</strong></p>
<table style="border-collapse: collapse;" border="1" width="100%" cellspacing="0" cellpadding="0"> <table style="border-collapse: collapse;" border="1" width="100%" cellspacing="0" cellpadding="0">
<thead> <thead>
<tr style="height: 21px;"> <tr style="height: 21px;">
<th style="text-align: center;"><strong>Sno</strong></th> <th style="text-align: center;"><strong>Sno</strong></th>
<th style="text-align: center;"><strong>ESI Account No</strong></th> <th style="text-align: center;"><strong>EPO Account No</strong></th>
<th style=" text-align: center;"><strong>Employee Contribution</strong></th> <th style=" text-align: center;"><strong>Employee Contribution</strong></th>
<th style=" text-align: center;"><strong>Employeer Contribution</strong></th> <th style=" text-align: center;"><strong>Employeer Contribution</strong></th>
<th style=" text-align: center;"><strong>No of days Present</strong></th> <th style=" text-align: center;"><strong>No of days Present</strong></th>
@ -67,7 +67,7 @@ if(!empty($companyinfo))
foreach($PFESI as $data) foreach($PFESI as $data)
{ {
$index++; $index++;
?> ?>
<tr style="height: 22px;"> <tr style="height: 22px;">
<td style="text-align: center;"><?php echo $index;?></td> <td style="text-align: center;"><?php echo $index;?></td>
<td ><?php echo $data->PFNO;?></td> <td ><?php echo $data->PFNO;?></td>
@ -77,7 +77,7 @@ if(!empty($companyinfo))
<td ><?php echo $data->OTperHours;?></td> <td ><?php echo $data->OTperHours;?></td>
<td ><?php echo number_format(($data->PF + $data->CompanyPF),2,'.','');?></td> <td ><?php echo number_format(($data->PF + $data->CompanyPF),2,'.','');?></td>
</tr> </tr>
<?php }}?> <?php }}?>
<tr style="height: 37px;"> <tr style="height: 37px;">
<td style="text-align: center;" colspan="2"><strong>Total</strong></td> <td style="text-align: center;" colspan="2"><strong>Total</strong></td>
<td style="text-align: left;"><strong><?php echo number_format($TotalEmployeeContribution,2,'.','');?></strong></td> <td style="text-align: left;"><strong><?php echo number_format($TotalEmployeeContribution,2,'.','');?></strong></td>