使用php的tcpdf额外空白页面

时间:2014-06-10 06:02:28

标签: php tcpdf

我使用TCPDF转换php生成的页面。在这里我使用pagebreak =" true"达到限制时的分页。所以当达到限制时,我得到一个额外的空白页面。如何删除此空白页?

tcpdf();
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$title = "Salary slip";
$obj_pdf->SetTitle($title);
$obj_pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, $title, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$obj_pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$obj_pdf->SetFont('helvetica', '', 9);
$obj_pdf->setFontSubsetting(false);
$obj_pdf->AddPage();
ob_start();
//$content = ob_get_contents();
$content = $this->load->view('templates/template',$data,true);
ob_end_clean();
$obj_pdf->writeHTML($content, true, false, true, false, '');
$obj_pdf->Output('pay_slip.pdf', 'I');

并在模板中

<?php $limit=1; foreach($salaries['salaries'] as $key =>$salary):?>
<?php   $limit+=$key;
        $limit1=$limit%4;


        if($limit1==0){
          ?><br pagebreak="true"/><?php

        }

1 个答案:

答案 0 :(得分:0)

尝试使用

.element:last-child {page-break-after:auto;}

其中&#39;元素&#39;是你的CSS选择器。