TCPDF SetAutoPageBreak()弄乱我的页脚缩放()

时间:2014-08-28 14:45:58

标签: php html html-table tcpdf image-scaling

我正在使用自定义页脚并使用setY();设置其位置。然而,内容在我的页脚后面继续,这意味着我需要让我的分页更高。当我有多个页面时,这会导致我的页脚大小搞乱。

我的页脚包含内部图像的表格。出现问题的是,通过某种缩放,图像变得奇怪!我制作的setAutoPageBreak()越大,我的页脚就会越搞乱。

我已经待了好几个小时了。我希望有人可以帮助我。

我的页脚:

 public function Footer() {
        $footer = '<table>
                        <tr>
                            <td width="30" height="50"></td>
                            <td style="width: 570px; height: 55px;">
                               <img src="some_image" width="30" height="50" />
                            </td>
                        </tr>                           
                   </table>                 
                ';

        $this->SetY(-60);           
        $this->writeHTML($footer, true, true, true, false, '');
    }

TCPDF处理:

$pdf = new MyPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);    
set margins
$PDF_MARGIN_LEFT = 20;
$PDF_MARGIN_TOP = 40;
$PDF_MARGIN_RIGHT = 20;
$pdf->SetMargins($PDF_MARGIN_LEFT, $PDF_MARGIN_TOP, $PDF_MARGIN_RIGHT);
//LTRB
$PDF_MARGIN_HEADER = 5;
$PDF_MARGIN_FOOTER = 60;
$pdf->SetHeaderMargin($PDF_MARGIN_HEADER);
$pdf->SetFooterMargin($PDF_MARGIN_FOOTER);

// set auto page breaks, it also specifies margin-bottom. This scales the footer somehow...
$PDF_MARGIN_BOTTOM = 20;
$pdf->SetAutoPageBreak(true, $PDF_MARGIN_BOTTOM);

// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

$pdf->AddPage();

// output the HTML content
$pdf->writeHTML($my_printed_html, true, false, true, false, '');

$pdf->Output('Test.pdf', 'I');

Editted:

我注意到只有在我的页脚低于分页符边距时才会出现问题。如果页脚位于其上方,则图像正常但内容从后面传递到页脚。 有没有办法绕过这个?

1 个答案:

答案 0 :(得分:1)

问题很容易解决,很遗憾失去了太多宝贵的时间。 在TCPDF中使用图像时,始终将图像的大小与希望它们位于pdf中的所需大小相匹配。如果setImageScale()超出页面范围,则它不会到达每个图像。这包括页脚,如果它的位置在页面margin_bottom之外。 我希望你们不要过多地伤害你的头脑,这样可以拯救你们所有人。

相关问题