fPDFとPHPでPDFテーブルを作成しようとしていて、1ページに収まる場合はテーブルを作成します。ただし、表が1ページに収まらない場合は、最初のページは良好ですが、2ページ目および他のページでは表は規則的ではありません。ここでは私のPDF出力の例です:複数のページにあるFpdfテーブル
https://rapidshare.com/files/486723233/results.pdf
そして、ここでは、このテーブルを作成するための私のコードは次のとおりです。
//FILL THE TABLE
$max_number_of_lines = 0;
for ($index = 0; $index < count($subjects); $index++,$temp=0,$row_height = 15,$max_number_of_lines = 0) {
//Account height of row, all will be same
//Issue a page break first if needed
if($this->GetY()+$row_height > $this->PageBreakTrigger)
$this->AddPage($this->CurOrientation);
foreach ($subjects[$index] as $fields) {
$myString = mb_convert_encoding($fields, "iso-8859-9", "auto");
$number_of_lines = ceil(($this->GetStringWidth($fields))/$fieldLengthArray[$temp]);
if ($row_height < ceil($number_of_lines * 15)) {
$row_height = ceil($number_of_lines * 15);
$max_number_of_lines = $number_of_lines+1;
}
$temp++;
}
$temp=0;
foreach ($subjects[$index] as $myFields) {
//$this->SetAutoPageBreak(true,$row_height);
$this->SetY($currentY);
$this->SetX($currentX);
$myString = mb_convert_encoding($myFields, "iso-8859-9", "auto");
$number_of_lines = ceil(($this->GetStringWidth($myFields))/$fieldLengthArray[$temp]);
if ($number_of_lines < $max_number_of_lines-1) {
$this->Rect($currentX, $currentY, $fieldLengthArray[$temp], $row_height);
//Draw the border
//$this->Rect($x, $y, $w, $h);
$this->MultiCell($fieldLengthArray[$temp], ceil($row_height/$max_number_of_lines) ,
$myString,0, 'L', $fill);
}
else {
//Draw the border
//$this->Rect($x, $y, $w, $h);
$this->Rect($currentX, $currentY, $fieldLengthArray[$temp], $row_height);
$this->MultiCell($fieldLengthArray[$temp], ceil($row_height/$max_number_of_lines),
$myString,0, 'L', $fill);
}
$currentX += $fieldLengthArray[$temp];
$temp++;
//$this->Ln();
}
$this->Ln($row_height);
$this->SetY($currentY);
$currentX = $this->GetX();
$currentY += $row_height;
}
$this->SetFillColor(238);
$this->SetLineWidth(0.2);
$this->SetFont('arial_tr', '', 10);
$this->Ln();
}
これは、テーブルを生成し、私の機能の一部であり、$subjects
は、情報iは、データベースから取得する。
$subjects = array(array())
それが最初のページに規則的であるとき、それは第二および他のページでは、正規ではない理由を私は理解できませんでした。私はまた、ページの終わりをチェックします。
どうもありがとう、それは今でokです。 – sinan