Reputation: 31
I am using dompdf library to convert html content to pdf.I am facing some problems.
1) I am able to generate pdf but On My HTML content there are some images but when I am generating pdf images are not coming in PDF.
2) Also PDF is not showing complete data means data is coming surely but not visible of complete width.
Please help!!!
Upvotes: 0
Views: 5338
Reputation: 1
why are you loading libraries twice?
// ...
$this->load->library('dompdf_gen');
$html = $this->load->view('contracts/equipment_pdf', $data, true);//this equipment_pdf contain the html that you will convert to pdf
$this->load->library('dompdf_gen');
$dompdf = new DOMPDF();
// ...
Upvotes: 0
Reputation: 538
Here is my sample of making my html to pdf...I wish i give you some idea
LIBRARIES:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Dompdf_gen {
public function __construct() {
require_once APPPATH.'third_party/dompdf/dompdf_config.inc.php';
$pdf = new DOMPDF();
$CI =& get_instance();
$CI->dompdf = $pdf;
}
}
Controller:
function pdf($id){
$data['contract_items_all'] = $this->contract_items->get_serial_infos($this->uri->segment(4));
$data['child_info'] = $this->contract_items->get_children_info($cid);
$this->load->library('dompdf_gen');
$html = $this->load->view('contracts/equipment_pdf', $data, true);//this equipment_pdf contain the html that you will convert to pdf
$this->load->library('dompdf_gen');
$dompdf = new DOMPDF();
// Convert to PDF
$this->dompdf->load_html($html);
$this->dompdf->render();
$this->dompdf->stream("Contract.pdf",array("Attachment"=>0)); // VIEW IN OTHER TAB
//$this->dompdf->stream("Contract.pdf"); // SAVE FILE TO DISK
}
Upvotes: 1