phpcodeignitermpdf

mpdf Skips CSS when i render the view into HTML?


i am using codeigniter i am working on invoice and i want to print a PDF file of my invoice page here is my controller.

$pdfFilePath ='invoice.pdf';
$data=$this->singleinvoice($invoiceId);
ini_set('memory_limit','32M');
$html = $this->load->view('invoice/invoicetopdf', $data, true);
$this->load->library('pdf');
$pdf = $this->pdf->load();
$pdf->SetFooter($_SERVER['HTTP_HOST'].'|{PAGENO}|'.date(DATE_RFC822)); 
$pdf->WriteHTML($html);
$pdf->Output($pdfFilePath, 'D');
redirect("invoice");

when i echo $html veriable is show fine but when it output the pdf .it has no css styling i mean it convert the HTML without any of my css Style. i also tried the following but no luck.

 $style=file_get_contents(base_url().'_assets/css/bootstrap.css');
 $pdf->WriteHTML($style,1);
 $pdf->Output($pdfFilePath, 'D');

Now i want to convert my HTML page to PDF as it is shown to the public with complete styling and markups. does it possible any suggestion or solution ?


Solution

  • you have to convert your Page Structure from DIV to Traditional Table structure. arrange your elements contents etc.into table or tables. then try some basic CSS. because most of CSS are not supported in mpdf or any other pdf converter.

    Click here to know what(CSS) is supported and what is not in mpdf.