FPDF 和分页符

问题描述

我正在生成一个横向 PDF,每行显示 9 列。我正在使用这些设置:

parent::__construct($orientation = 'L',$unit = 'mm',$size = 'A4');
$this->SetdisplayMode(100);
$this->setAutopageBreak(true,15);
$this->setMargins(0,18);
$this->AliasNbPages();
$this->AddPage();

一旦到达第一页的末尾,就会在第二页的顶部打印第一个单元格。没有其他的!?在第三页上,打印第二个单元格,依此类推,直到第 10 页,其中打印第 9 列和所有其他行 - 以下行是完整的并且都在第 10 页上。每个“孤独”单元格都在其正确的位置.唯一的问题是,它们应该在同一页面上。

谁能告诉我我的错误隐藏在哪里?

谢谢 奥利弗

解决方法

问题是当您使用 SetXY() 时,FPDF 似乎无法进行正确的分页。 我现在寻找实际的 GetY(),当它变大时,我使用 AddPage() 并将 y 重置为合适的值。 以下是填充行(HTH)的相关代码:

    foreach ($daten as $datum) {
        $this->SetXY(5,$y);
        $this->Cell(20,4,strftime( "%d.%m.%Y",strtotime($datum["date"])),$border);
        //.......  some more code
        $this->SetXY(261,$y);
        $this->Cell(25,number_format($datum["rate"],2,","." ) . iconv( 'UTF-8','windows-1252'," €" ),$border,"R");
        //make corrections in case of a MultiCell-line - there MAY be two of them
        if ($y2 > $y+4 OR $y3 > $y+4) {
            if ($y2 > $y+4) {
                $y = $y2+1;
            } else {
                $y = $y3+1;
            }
        } else {
            $y = $this->GetY() + 5;
        }
        if ($y > 190) {                                             //do we need a new page?
            $y = 22;
            $this->AddPage();
        }
    }