我正在使用FPDF库根据查询生成PDF。我目前的代码在A4横向页面上创建了三列布局。我希望能够在创建新列之前为每列指定固定的行数。
有人知道如何指定每列有多少行吗?目前,它以34行停止,我希望是49行。
到目前为止,我的代码是:
var $col = 0;
function SetCol($col)
{
// Move position to a column
$this->col = $col;
$x = 60+$col*65;
$this->SetLeftMargin($x);
$this->SetX($x);
}
function AcceptPageBreak()
{
if($this->col<2)
{
// Go to next column
$this->SetCol($this->col+1);
$this->SetY(10);
return false;
}
else
{
// Go back to first column and issue page break
$this->SetCol(0);
return true;
}
}
global $pdf;
$title_line_height = 10;
$content_line_height = 8;
$pdf->AddPage('L');
$pdf->SetFont( 'Arial', '', 42 );
$header = array('Order Number', 'Full name (Billing)', 'Draw #');
foreach($header as $col) {
$pdf->SetFont( 'Arial', '', 8);
$pdf->Cell(40,2,$col,1);
}
$pdf->Ln();
foreach( $log as $row ) {
$pdf->SetFont( 'Arial', '', 8 );
$pdf->Cell(40,5,$row->orderid, 1);
$pdf->Cell(40,5, $row->firstname .' '. $row->lastname, 1);
$pdf->Cell(40,5,$row->ticketid,1);
$pdf->Ln();
}
}
}
$pdf->Output('D','atomic_smash_fpdf_tutorial.pdf');