fpdf 为什么要为每个单元格创建一个新页面?
fpdf why does it create a new page for every cell?
我正在尝试使用 fpdf 创建发票,如果它到达底部,我希望内容在下一页继续。因此,例如,我使用此代码打印行以转到下一页。
$y = 150;
for($i = 0;$i < 50;$i++) {
$pdf->setXY(150,$y);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(10,10,'Inclusief BTW: ');
$y += 5;
}
在这里它会像我预期的那样正常运行。
但是在第二页上它显示一次。
还为每个单元格创建了 23 页,使用了 1 页,我希望它在第二页上继续,就像在第一页上一样。
完整代码:
<?php
require('fpdf.php');
test();
function test() {
$pdf = new FPDF();
$pdf->addPage();
$y = 5;
$pdf->SetFont('Arial','I',10);
for($i = 0;$i < 150;$i++) {
$pdf->setXY(10,$y);
$pdf->Cell(10,10,"Inclusief BTW",0,1);
$y += 5;
}
$pdf->output();
}
?>
尝试使用以下代码:
$pdf->setXY(10,$y);
for($i = 0;$i < 150;$i++) {
$pdf->Cell(5, 5, "Inclusief BTW", 0, 1);
}
我正在尝试使用 fpdf 创建发票,如果它到达底部,我希望内容在下一页继续。因此,例如,我使用此代码打印行以转到下一页。
$y = 150;
for($i = 0;$i < 50;$i++) {
$pdf->setXY(150,$y);
$pdf->SetFont('Arial','B',10);
$pdf->Cell(10,10,'Inclusief BTW: ');
$y += 5;
}
在这里它会像我预期的那样正常运行。
完整代码:
<?php
require('fpdf.php');
test();
function test() {
$pdf = new FPDF();
$pdf->addPage();
$y = 5;
$pdf->SetFont('Arial','I',10);
for($i = 0;$i < 150;$i++) {
$pdf->setXY(10,$y);
$pdf->Cell(10,10,"Inclusief BTW",0,1);
$y += 5;
}
$pdf->output();
}
?>
尝试使用以下代码:
$pdf->setXY(10,$y);
for($i = 0;$i < 150;$i++) {
$pdf->Cell(5, 5, "Inclusief BTW", 0, 1);
}