Convert html to pdf, adjust the width
I have a table with around 10 columns in my html page , when i am converting to pdf, last colums are truncated. how to solve this problem.is there any PDF landscape option?
workin in codeigniter: using dompdf converter
$this->load->plugin('to_pdf');
$this->load->helper('file');
$html = $this->开发者_如何学Goload->view('export_pdf'), $data, TRUE);
pdf_create($html, $this->session->userdata('site_id'),TRUE);
}
I also used pdf_create($html, $this->session->userdata('site_id'),TRUE,$papersize = 'a3', $orientation = 'landscape');
but what where paper size and orientation i give the result issame
If you are using codeigniter, with dompdf helper you can use this modification in helpers/dompdf_helper.php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
function pdf_create($html, $filename, $stream=TRUE)
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper("a4");
$dompdf->render();
$dompdf->stream($filename . ".pdf");
}
function pdf_create_params($html, $filename, $stream=TRUE, $paper = 'a4', $orientation = "portrait")
{
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->set_paper($paper, $orientation);
$dompdf->render();
$dompdf->stream($filename . ".pdf");
}
?>
Instead calling pdf_create call pdf_create_params and use the params you want. By default it has A4 and portrait.
Use
pdf_create($html, $this->session->userdata('site_id'),TRUE, 'a3', 'landscape');
I had a similar problem. I did not manage to adjust my columns width after using :
$htmlToPdf->WriteHTML($this->view->render($fileRender));
To solve this, just apply the style attribute to your td too, in your view file
<td style:"width:10%;"> </td>
精彩评论