我有这个HTML代码,我将用它添加到我的.pdf
文件中:
<style>
table{
width:783px;
height:auto;
table-layout:fixed;
}
</style>
<table>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
<tr>
<th style="width:783px; height:300px; border:1px solid black;">Firstname</th>
</tr>
</table>
以下是我用来生成.pdf
文件的代码:
define("DOMPDF_ENABLE_HTML5PARSER", true);
define("DOMPDF_ENABLE_FONTSUBSETTING", true);
define("DOMPDF_UNICODE_ENABLED", true);
define("DOMPDF_DPI", 120);
define("DOMPDF_ENABLE_REMOTE", true);
//Configure the directory where you have the dompdf
require_once "dompdf/autoload.inc.php";
use Dompdf\Dompdf;
//$dompdf = new dompdf();
//$dompdf = new DOMPDF();
$dompdf = new Dompdf();
$dompdf->loadHtml($htmlOut);
// (Optional) Setup the paper size and orientation
$dompdf->setPaper('A4', 'portrait');
// Render the HTML as PDF
$dompdf->render();
// Output the generated PDF to Browser
$dompdf->stream();
此代码有一个问题...我的行有300px的高度,当我打开我的pdf文件时,在第一页中高度正常(有300px)在第二页第一行有300px,但之后,他们恢复到正常高度。
发生了什么,以及如何解决这个问题?
答案 0 :(得分:1)
<th style="width:783px; height:300px; min-height:300px; border:1px solid black;">Firstname</th>
或
<th><div style="width:783px; height:300px; min-height:300px; border:1px solid black;">Firstname</div></th>
我很想听听结果。