我正在使用dompdf在codeigniter中生成PDF,正在生成pdf,但图像/徽标没有被选中。 我试图在我看来以下列方式引用我的徽标:
<img src="<?php echo base_url()?>assets/img/shwari.png">
以下是我的控制器,我无法加载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);
}
}
使用DOMPdf将图像加载到pdf的最佳方法是什么?
答案 0 :(得分:1)
如果DOMPDF关心URL,那么<img src="<?php echo base_url()?>assets/img/shwari.png">
应该可以工作,但我猜你需要一个服务器路径:
<img src="C:/I/Dont/Know/Your/Exact/Path/But/You/Should/Use/It/Here/assets/img/shwari.png">
在我的应用中,它将是
<img src="D:/web/sites/example.com/public_html/resources/images/my_image.png">