Im working with fpdf that display two images every page, but it only display one picture every page. Here is my code:
foreach ($imageList as $image) {
$pdf->AddPage();
$pdf->Image('dealers_picture/'.$image['name'],30,30,160,110);
}
CodePudding user response:
I thing you are overlapping the pictures, increase the X size in second image.
$images=['image1','image2'];
$x=30
for ($i = 0; $<2 ; $i ) {
$pdf->AddPage();
$pdf->Image('dealers_picture/'.$image[$i],$x,30,160,110);
$x =200;
}
CodePudding user response:
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
//$pdf->Output();
$images = '["images/er.jpg","images/dc.jpg","images/g.jpg","images/7.jpg","images/4.jpg","images/2.jpg"]';
$imgs = json_decode($images);
//var_dump($imgs);
for($i=0;$i<count($imgs);$i =1)
{
if(isset($imgs[$i 1])){
if($i % 2==0){
$pdf->Image($imgs[$i],10,12,40,30,'','');
$pdf->Image($imgs[$i 1],60,12,40,30,'','');
//echo $imgs[$i]." ".$imgs[$i 1];
//echo "<hr/>";
$pdf->AddPage();
}
}
else
{
$pdf->Image($imgs[$i],10,12,40,30,'','');
//echo $imgs[$i];
//echo "<hr/>";
}
}
$pdf->Output();
?>