问题
I'm using the PHP class TCPDF's writeHTML method for creating a PDF document. It works great and seems to cover what I need, but when I try to create multiple images in a straight line using HTML elements in a sequence the images are not rendered in the straight line that I expect. Instead, the position of every sequential image is increased (or decreased in some cases) by a few pixels on the y axis, hence making the sequence of images look like a "staircase":
What I expect (every x is a picture):
x x x
What I get:
x
x
x
Sometimes I get it the other way around:
x
x
x
The HTML markup looks like this:
<img src="x.png"><img src="x.png"><img src="x.png"><img src="x.png">
HTML does not normally behave this way and I have not found any solutions by Googling. Any help would be appreciated! Thanks.
回答1:
Have you considered trying to put it in a table?
<table>
<tr>
<td>
<img src="x.png">
</td>
<td>
<img src="x.png">
</td>
<td>
<img src="x.png">
</td>
<td>
<img src="x.png">
</td>
</tr>
</table>
来源:https://stackoverflow.com/questions/10747262/tcpdf-writing-multiple-images-after-eachother-using-writehtml-renders-images-in