TCPDF: Writing multiple images after eachother using writeHTML renders images in a “staircase” shape instead of in a straight line

*爱你&永不变心* 提交于 2019-12-24 07:59:23

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!