我正在尝试使用mPDF将HTML转换为PDF,但在执行此操作时,对齐会产生干扰。
我的HTML使用
为此生成highlight_string($html);
如下所示:
"<body style="height:11in;width:8.5in;">
<table style='margin-left:0.25in;margin-right:0.25in;margin-bottom:in;margin-top:1in;'>
<tr>
<td>
<div style="background:#9abdd6;margin-left:0.25in;margin-right:0.25in;margin-bottom:in;margin-top:1in; height:3in;width:4in; position: relative; float:left; ">
<div style="height:3in; width:4in;background:#9abdd6">
</div>
<div style ="position:absolute;float:left;left:99px;background:;top:204px;width:auto;height:auto;color:gray;scaleX:0.51px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<div style="left:99px;top:204px;width:196.86px;height:40px;background-color:gray">
</div>
</div>
<div style ="position:absolute;float:left;left:131px;background:;top:215px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
Darshan</div>
<div style ="position:absolute;float:left;left:149px;background:;top:105px;width:auto;height:auto;color:rgb(0,0,0);scaleX:1px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<img src="http://192.168.1.51/mleads9.6/user_files/1403762976/sponsor/Chrysanthemum.jpg" width="100" height="100"/>
</div>
<div style ="position:absolute;float:left;left:316px;background:;top:206px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
</div>
</div>
</td>
<td>
<div style="background:#9abdd6;margin-left:0.25in;margin-right:0.25in;margin-bottom:in;margin-top:1in; height:3in;width:4in; position: relative; float:left; ">
<div style="height:3in; width:4in;background:#9abdd6">
</div>
<div style ="position:absolute;float:left;left:99px;background:;top:204px;width:auto;height:auto;color:gray;scaleX:0.51px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<div style="left:99px;top:204px;width:196.86px;height:40px;background-color:gray">
</div>
</div>
<div style ="position:absolute;float:left;left:131px;background:;top:215px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
Trainee</div>
<div style ="position:absolute;float:left;left:149px;background:;top:105px;width:auto;height:auto;color:rgb(0,0,0);scaleX:1px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<img src="http://192.168.1.51/mleads9.6/user_files/1403762976/sponsor/Chrysanthemum.jpg" width="100" height="100"/>
</div>
<div style ="position:absolute;float:left;left:316px;background:;top:206px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
</div>
</div>
</td>
</tr>
<tr>
<td>
<div style="background:#9abdd6;margin-left:0.25in;margin-right:0.25in;margin-bottom:in;margin-top:1in; height:3in;width:4in; position: relative; float:left; ">
<div style="height:3in; width:4in;background:#9abdd6">
</div>
<div style ="position:absolute;float:left;left:99px;background:;top:204px;width:auto;height:auto;color:gray;scaleX:0.51px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<div style="left:99px;top:204px;width:196.86px;height:40px;background-color:gray">
</div>
</div>
<div style ="position:absolute;float:left;left:131px;background:;top:215px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
Darshan</div>
<div style ="position:absolute;float:left;left:149px;background:;top:105px;width:auto;height:auto;color:rgb(0,0,0);scaleX:1px;scaleY:1px;opacity:1px;font-size:;font-weight:;font-family:;text-align:">
<img src="http://192.168.1.51/mleads9.6/user_files/1403762976/sponsor/Chrysanthemum.jpg" width="100" height="100"/>
</div>
<div style ="position:absolute;float:left;left:316px;background:;top:206px;width:auto;height:auto;color:black;scaleX:1px;scaleY:1px;opacity:1px;font-size:20px;font-weight:normal;font-family:Times New Roman;text-align:center">
</div>
</div>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</body>"
显示完美的HTML结果......
我使用的代码是:
$mpdf = new mPDF();
$mpdf->allow_output_buffering = true;
$mpdf->WriteHTML($html);
$mpdf->Output();
但是当我将其转换为PDF时,对齐完全令人不安。
答案 0 :(得分:0)
mPDF不支持“浮动”。 另一种方法是使用嵌套表。 我建议你尽可能只使用表格标签,不要使用div或span。
答案 1 :(得分:-2)
mPDF不支持在表内浮动。