TCPDF:使用 writeHTML 逐个写入多个图像会在“楼梯"中呈现图像.形状而不是直线 [英] TCPDF: Writing multiple images after eachother using writeHTML renders images in a "staircase" shape instead of in a straight line

查看:32
本文介绍了TCPDF:使用 writeHTML 逐个写入多个图像会在“楼梯"中呈现图像.形状而不是直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 PHP 类 TCPDF 的 writeHTML 方法来创建 PDF 文档.它工作得很好,似乎涵盖了我需要的东西,但是当我尝试使用 HTML 元素按顺序以直线创建多个图像时,图像不会以我期望的直线呈现.相反,每个连续图像的位置在 y 轴上增加(或在某些情况下减少)几个像素,因此使图像序列看起来像一个楼梯":

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":

我所期望的(每个 x 都是一张图片):

What I expect (every x is a picture):

x x x

我得到了什么:

x
 x
  x

有时我会反其道而行之:

Sometimes I get it the other way around:

  x
 x
x

HTML 标记如下所示:

The HTML markup looks like this:

<img src="x.png"><img src="x.png"><img src="x.png"><img src="x.png">

HTML 通常不会以这种方式运行,我还没有通过谷歌搜索找到任何解决方案.任何帮助,将不胜感激!谢谢.

HTML does not normally behave this way and I have not found any solutions by Googling. Any help would be appreciated! Thanks.

推荐答案

您是否考虑过尝试将其放入表格中?

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>

这篇关于TCPDF:使用 writeHTML 逐个写入多个图像会在“楼梯"中呈现图像.形状而不是直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆