doupian9798 2017-06-05 03:26 采纳率: 100%
浏览 466

dompdf图像不起作用

The images do not appear loop. Only the first image appears the rest does not.

$namePic = "";
    foreach($_POST['ck'] as $ck){
        $namePic.= $ck.", ";
        $namesPic = explode(",", $namePic);
    }

$dompdf = new DOMPDF();
$html = "";

    for($i = 0; $i < $count; $i ++){
       $html.= "<html><head><style type='text/css'> </style></head><body><div style=\"page-break-after: always;\"><p align=\"center\"><img src=\"../folder/images/$namePic[$i]\" ></p></div>";
    }

$html.= "</body></html>";

$dompdf->load_html($html);
$dompdf->set_paper("a4", "portrail");
$dompdf->render();
$pdf = $dompdf->output();
$folder = "../sample.pdf";
file_put_contents($folder,$pdf);

With this I can generate the pdf, but it does not show all the images of the loop shows only the first image. How can I do to show all the images in my loop?

  • 写回答

1条回答 默认 最新

  • dongwei3120 2017-06-13 15:08
    关注

    Just remove your var $namePic[$i] from your string and use concatenation

    $html.= "<html><head><style type='text/css'> </style></head><body><div style=\"page-break-after: always;\"><p align=\"center\"><img src=\"../folder/images/".$namePic[$i]."\" ></p></div>";
    
    评论

报告相同问题?