[英]FPDF and page break
我正在橫向生成一個 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 頁上。每個“孤獨”單元格都是在它的右邊 position,唯一的問題是。 它們應該在同一頁面上。
誰能告訴我我的錯誤隱藏在哪里?
謝謝奧利弗
問題是當您使用 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, 4, number_format($datum["rate"], 2, ",", "." ) . iconv( 'UTF-8', 'windows-1252', " €" ), $border,0,"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();
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.