我正在使用 TCPDF 生成 pdf。第一个PDF最终生成了一个空白页面,但我通过删除第2页来修复它。问题是,PDF背景颜色没有设置为整页。pdf页面底部大约有100px长的高度空间,没有背景颜色。我需要从上到下的浅蓝色页面背景颜色。我的文档没有页眉或页脚。这是代码:
<?php
require_once('tcpdf/tcpdf.php');
// create new PDF document
$pagelayout = array(430,330); // or array($height, $width)
//define ('PDF_MARGIN_TOP', 19);
//new TCPDF('p', 'pt', $pageLayout, true, 'UTF-8', false);
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, $pagelayout, true, 'UTF-8', false);
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(0, 0, 0);
//$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(0);
// set auto page breaks
//$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// ---------------------------------------------------------
// set font
$pdf->SetFont('helvetica', '', 9);
// add a page
$pdf->AddPage();
$pdf->setPageMark();
$html = '<body>
<table height="800" style="background-color: rgb(232,239,242);width:100%" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" align="center">
<img src="images/Logopdf.png" width="545" border="0" />
<img src="images/star.png" width="859" height="43" />
</td>
</tr>
<tr>
<td colspan="3">
<div style="margin:0 auto; width:100%;">
<div style="float:left; margin:0px 0px 0px 70px; border:none;">
<img src="'.$img1.'" width="415" height="518" align="left" /> <img src="'.$img2.'" width="415" height="518" align="left"/><br><div style="margin-top:35%;"><div> <img src="images/star.png" width="859" height="43" style="margin-top:50px;" /></div>
</div></div>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<div style="margin:0 auto; width:100%;">
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56); ">
<span class="topname" style="color: rgb(82, 59, 56); font-weight: bold;text-transform:uppercase;"><font size="+8"> '.strtoupper($unique_profile['name']).'</font></span></div>
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56);">
<span style="color: rgb(82, 59, 56);"><font size="+6"> D.O.B :
'.$unique_profile['birthday'].'</font></span></div>
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56);">
<span style="color: rgb(82, 59, 56);"><font size="+6">HEIGHT : '.$unique_profile['height'].'CMS</font></span></div>
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56);">
<span style="color: rgb(82, 59, 56);"><font size="+5">SHOE SIZE : '.$unique_profile['shoe_no'].'</font></span></div>
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56);">
<span style="color: rgb(82, 59, 56);"><font size="+6">AGE : '.$final_year.'</font></span></div>
<div style="float:left; margin:20px 0px 0px 0px; width:100%; color: rgb(82, 59, 56);">
<span style="color: rgb(82, 59, 56);"><font size="+6">HAIR : '.$unique_profile["hair_color"].'</font></span></div>
</div>
<div style="float:left; margin:20px 0px 0px 0px;"> <span style="color: rgb(82, 59, 56);"><font size="+6">TEL 01883 744488 INFO@GRACEANDGALOR.COM</font></span></div>
<div style="float:left; margin:200px 0px 0px 0px;">
</div>
<div>
</div>
</td>
</tr>
<tr>
<td style="width:20%"></td>
<td style="width:40%">
<table >
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td style="width:20%"></td>
<td style="width:40%">
</td>
<td style="width:30%"></td>
</tr>
</table>
</td>
</tr>
</table>
</body>';
$pdf->writeHTML($html,true, true, false);
// reset pointer to the last page
$pdf->lastPage();
$pdf->deletePage(2);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output('my_document.pdf', 'D');
//============================================================+
// END OF FILE
//============================================================+
?>
请建议我如何才能为 pdf 文件的整个第 1 页设置浅蓝色背景。底部不应有空白。