H Dindi
H Dindi

Reputation: 1552

Load Image in DOM PDF

I am using dompdf to generate PDF in codeigniter, the pdf is being generated but the image/logo is not picking. I have tried to reference my logo in the following way in my view :

 <img src="<?php echo base_url()?>assets/img/shwari.png">

Below is my controlller which I am usnig to load the pdf :

class Dompdf_test extends CI_Controller {

    public function index() {


        $this->all_movements();
        // Get output html
        $html = $this->output->get_output();

        // Load library
        $this->load->library('dompdf_gen');

        // Convert to PDF
        $this->dompdf->load_html_file($html);

        $this->dompdf->render();
        $min = 1;
        $max = 1000;
        $name = rand($min, $max);
        $this->dompdf->stream($name . '.pdf');
    }

    public function all_movements() {


         $data['stocks'] = $this->inventory->getdepartmentalmovements();
        $data['meds'] = $this->inventory->get_meds();
        $this->load->view('dompdf', $data);


    }

}

What is the best way load the image to the pdf using DOMPdf?

Upvotes: 0

Views: 3758

Answers (1)

MonkeyZeus
MonkeyZeus

Reputation: 20757

If DOMPDF cares about the URL then <img src="<?php echo base_url()?>assets/img/shwari.png"> should work but I would guess that you need a server path instead:

<img src="C:/I/Dont/Know/Your/Exact/Path/But/You/Should/Use/It/Here/assets/img/shwari.png">

In my app it would be

<img src="D:/web/sites/example.com/public_html/resources/images/my_image.png">

Upvotes: 1

Related Questions