php – 表格在html中很好地显示,但在用mpdf生成的pdf中没有
作者:互联网
我正在尝试使用mPDF在PHP中生成PDF.
我的文档的一部分必须是这样的:http://cloudandfun.com/Capture.PNG
所以我写了HTML:
<table style = "width:100%">
<tr>
<td>Appellation <br>(par ordre de préférence)</td>
<td style = "border:0px;">
<table style = "width:100%; border:0px;">
<tr style = "border:0px;"><th style = "border:0px;">Abréviation (S’il y a lieu)</th></tr>
</table>
<table style = "width:100%;border:0px;">
<tr style = " border:0px;">
<td style = "width:33%;border-bottom:0px;border-left:0px;">Abréviation</td>
<td style = "width:33%;border-bottom:0px;border-left:0px;">Facultative</td>
<td style = "width:33%;border-bottom:0px;border-left:0px;border-right:0px;">Obligatoire</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>1.</td>
<td>
<table style = "width:100%;border:0px;">
<tr style = " border:0px;">
<td style = "width:33%;border-bottom:0px;border-left:0px;border-top:0px;">--</td>
<td style = "width:33%;border-bottom:0px;border-left:0px;border-top:0px;">--</td>
<td style = "width:33%;border:0px;">--</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>2.</td>
<td>
<table style = "width:100%;border:0px;">
<tr style = " border:0px;">
<td style = "width:33%;border-bottom:0px;border-left:0px;border-top:0px;">--</td>
<td style = "width:33%;border-bottom:0px;border-left:0px;border-top:0px;">--</td>
<td style = "width:33%;border:0px;">--</td>
</tr>
</table>
</td>
</tr>
我的CSS:
th,td,tr {
border:1px solid black;
border-collapse:collapse;
}
table {
border:2px solid black;
border-collapse:collapse;
}
td {
font-family:Arial;
font-size:11px;
}
在html页面中,它工作得很好,但是当生成pdf时,它看起来像这样:http://cloudandfun.com/Capture1.PNG
有人有解决方案吗?提前致谢.
解决方法:
我已经得到了解决方案,而不是给%我用px给出宽度并且它有效.
结论:mPDF不支持%(宽度:33%;对于我的示例)但支持px(宽度:100px;对于我的示例). ;);)
标签:php,html,mpdf 来源: https://codeday.me/bug/20190528/1173848.html