-->

Html2Pdf -Codeigniter -Image not loading

2019-08-06 14:35发布

问题:

I am using HTML2PDF Library for codeigniter

See:https://github.com/aiwmedia/HTML2PDF-CI My problem is i am unable to load images using tag. Instead of image it always shows alt attribute. Tried giving the full path and relative path.

View:

<img src="<?php echo base_url(); ?>/uploads/pdf_images/1.jpg" alt="<?php echo base_url(); ?>uploads/pdf_images/1.jpg"/>

Controller:

$this->load->library('html2pdf');
$this->html2pdf->folder(APPPATH."third_party/samples/");
$file_name=$this->random_string(7);
$this->html2pdf->filename($file_name.'.pdf');
$this->html2pdf->paper('a4', 'portrait');
//$this->html2pdf->html($this->load->view('pdfcouple',$data,true));
if($user_details_arr[0]->is_married)
{
    $content=$this->load->view('pdfcouple', $data, true);
}
$this->html2pdf->html($content);
$this->html2pdf->create('save');

回答1:

I solved the issue by editing dompdf_config.custom.inc.php

uncommented

define("DOMPDF_ENABLE_REMOTE", true);

Now the images are loading inside pdf. Thanks for the support.