问题
I must add a linebreak for my images to appear after each other. I have tried the following but it does not work.
$rs['imagepath'] = $imagepath;
$pdf->Image("{$imagepath}\n");
The original code to output the images is below, but it outputs only the first index and the second and third images does not come up... :(
$rs['imagepath'] = $imagepath;
$pdf->Image("{$imagepath}");
The result is in a foreach loop like this:
foreach($select as $index => $rs)
{
$rs['imagepath'] = $imagepath;
$pdf->Image("{$imagepath}");
}
回答1:
You can use ln() function i think.you have to define every image in one line
$fpdf->ln();
回答2:
I think your code has a mistake, try the below code to iterate over the $rs
array. in the current code, your $imagepath
variable is always remain same. you can then print a \n
characters to pdf for printing new lines
foreach($select as $index => $rs)
{
$imagepath = $rs['imagepath'];
$pdf->Image("{$imagepath}");
}
Edit: I found this on another stack overflow thread
If you are using fpdf, in order to be able to use line breaks you will need to use a multi-line text cell as described here.
If you use this, then line breaks in your text should be interpreted and converted correctly.
Just a quick example:
$pdf->Multicell(0,2,"This is a multi-line text string\nNew line\nNew line");
Here, 2 is the height of the multi-line text box. I don't know what units that's measured in or if you can just set it to 0 and ignore it. Perhaps try it with a large number if at first, it doesn't work.
来源:https://stackoverflow.com/questions/44735899/adding-linebreak-on-fpdf-cells