0
我正嘗試使用HTML2PDF庫從HTML文件生成PDF。HTML2Pdf內容溢出頁面
我的HTML:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top">
<table width="968" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<strong>Invoice </strong>
</td>
</tr>
<tr>
<td align="right" valign="top">
<span style="text-align:right;">#24638 </span>
</td>
</tr>
<tr>
<td align="left" valign="top">
<table width="968" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="50%" align="left" valign="top">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">To</td>
</tr>
<tr>
<td align="left" valign="top">test user
<br />
Some Company22
<br />
My Address
<br />
Line 2
<br />
City, 487030
<br />
State, Country
</td>
</tr>
</table>
</td>
<td width="50%" align="left" valign="top"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top">
<table width="968" border="1" cellspacing="1" cellpadding="1">
<tr>
<td width="17%" align="center" valign="top">Transaction Date</td>
<td width="6%" align="center" valign="top">User ID</td>
<td width="26%" align="center" valign="top">UserName</td>
<td width="9%" align="center" valign="top">Order</td>
<td width="21%" align="center" valign="top">Tax </td>
<td width="21%" align="center" valign="top">Tax Description</td>
</tr>
<tr>
<td align="center" valign="top">04-11-2015</td>
<td align="center" valign="top">137</td>
<td align="center" valign="top">[email protected]</td>
<td align="center" valign="top">24727</td>
<td align="center" valign="top">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</td>
<td align="center" valign="top">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Mauris placerat </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top">
<table width="968" border="1" align="left" cellpadding="1" cellspacing="1">
<tr>
<td width="49%" align="center" valign="top">Description</td>
<td width="27%" align="center" valign="top">Invoice Amount</td>
<td width="24%" align="center" valign="top">Pending Amount</td>
</tr>
<tr>
<td align="center" valign="top">Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo</td>
<td align="center" valign="top">USD 5.98 </td>
<td align="center" valign="top">USD 0 </td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top">
<table width="500" border="1" cellspacing="1" cellpadding="1">
<tr>
<td width="51%" align="left" valign="top">Foreign Exchange Rate when Invoice was paid (EUR To USD) </td>
<td width="49%" align="left" valign="top">Mauris placerat </td>
</tr>
<tr>
<td align="left" valign="top">Total Amount</td>
<td align="left" valign="top">USD 5.98</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top"> </td>
</tr>
</table>
</td>
</tr>
我使用此代碼GERATE的PDF:在輸出
$pdfdata = myHtml() // returns my generated HTML
require_once(__DIR__.'path/to/html2pdf/html2pdf.class.php');
try{
$html2pdf = new HTML2PDF('P','A4','en');
$html2pdf->WriteHTML($pdfdata);
$html2pdf->Output('transaction.pdf');
}catch(Exception $e){
echo $e->getMessage();
}
所以,你有什麼問題嗎?你嘗試了什麼? – sourcx
將寬度設置爲968可能是這裏的問題 – sofl
嘗試過,不起作用 – Mohan