作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
SetAutoPageBreak 不起作用或者我没有正确使用它。它会在页脚之前停止第一页,但之后的每一页都只打印一行,再打印 39 页。我做错了什么。我找不到有关添加更多信息以使其正常工作的更多信息。这是一个链接http://notaryaccounting.com/doc-2.pdf到输出文件,这样你就可以看到
class PDF extends tcpdf
{
// Page header
function Header()
{
$this->SetFont('dejavusans', 'BI', 20, '', 'false');
$this->setTextShadow(array('enabled'=>true, 'depth_w'=>0.2, 'depth_h'=>0.2, 'color'=>array(196,196,196), 'opacity'=>1, 'blend_mode'=>'Normal'));
// Move to the right
$this->Ln(5);
$this->Cell(60);
$this->Cell($w, $h=0, $txt='INCOME REPORT', $border=0, $ln=0, $align='', $fill=false, $link='', $stretch=0,
$ignore_min_height=false, $calign='T', $valign='M');
$this->Line (0, 13, 210, 13, $style=array());
// Line break
$this->Ln(5);
}
// Page footer
public function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 10, 'Page '.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
$pdf = new PDF();
$pdf->AddPage();
$pdf->SetAutoPageBreak(TRUE,20);
$pdf->SetFont('arial','B',12);
$y_axis = 20;
//Set Row Height
$row_height = 6;
//Go to next row
$y_axis = $y_axis + $row_height;
//initialize counter
$pageLine = 0;
//Set maximum rows per page
$itemsPerPage = 5;
$result = $db->query("Select
customers.name,
signings1.signstart,
signings1.fname,
signings1.lname,
signings1.city,
signings1.state,
signings1.samount,
signings1.prtamount,
signings1.faxamount
From
customers Inner Join
signings1 On customers.custid = signings1.custid
Where
signings1.pid = 6 And
signings1.done = 1
Order By
customers.name ,
signings1.signstart ");
$current=null;
foreach($result as $key => $income) {
if($current!=$income['name']){
$pdf->SetY($y_axis);
$pdf->SetFillColor(0,68,150);
$pdf->SetTextColor (252,252,252);
$pdf->SetX(05);
$pdf->Cell(200,6,'Customer:' . ' ' . $income['name'] ,1,0,'L',1);
//print column titles for the current page
$y_axis = $y_axis + 6;
$pdf->SetY($y_axis);
$pdf->SetFillColor(0,68,120);
$pdf->SetTextColor (252,252,252);
$pdf->SetX(05);
$pdf->Cell(30,6,'Date:',1,0,'L',1);
$pdf->Cell(70,6,'Name:',1,0,'L',1);
$pdf->Cell(70,6,'Location:',1,0,'L',1);
$pdf->Cell(30,6,'Amount:',1,0,'L',1);
$current = $income['name'];
}
$y_axis = $y_axis + $row_height;
$pdf->SetY($y_axis);
$pdf->SetX(05);
$pdf->SetTextColor (0,0,0);
$total = $income['samount'] + $income['prtamount'] + $income['faxamount'];
$name = $income['fname'] . ' ' .$income['lname'];
$signdate=phpdate($income['signstart']);
$pdf->Cell(30,6,$signdate,1,0,'L',0);
//$pdf->Cell(10,6,$income['custid'],1,0,'L',0);
$pdf->Cell(70,6,$name,1,0,'L',0);
$pdf->Cell(70,6,$income['city'],1,0,'L',0);
$pdf->Cell(30,6,$total,1,0,'L',0);
}
$pdf->Output();
最佳答案
你可以试试这个:
<?php
require ('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
$this->SetFont('Arial', 'BI', 20);
$this->Ln(5);
$this->Cell(60);
$this->Cell(190,10,'INCOME REPORT','B',1,'C',0);
// Line break
$this->Ln(5);
}
// Page footer
function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}','T',0,'C',0);
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('arial','B',12);
$result = $db->query("Select
customers.name,
signings1.signstart,
signings1.fname,
signings1.lname,
signings1.city,
signings1.state,
signings1.samount,
signings1.prtamount,
signings1.faxamount
From
customers Inner Join
signings1 On customers.custid = signings1.custid
Where
signings1.pid = 6 And
signings1.done = 1
Order By
customers.name ,
signings1.signstart ");
$current=null;
foreach($result as $key => $income) {
if($current!=$income['name']){ /* PROCEED WHEN THE LAST NAME IS NOT THE SAME WITH THE CURRENT NAME */
$pdf->SetFillColor(0,68,150);
$pdf->SetTextColor (252,252,252);
$pdf->Cell(200,6,'Customer:' . ' ' . $income['name'] ,1,1,'L',1);
//print column titles for the current page
$pdf->SetFillColor(0,68,120);
$pdf->SetTextColor (252,252,252);
$pdf->Cell(30,6,'Date:',1,0,'L',1);
$pdf->Cell(70,6,'Name:',1,0,'L',1);
$pdf->Cell(70,6,'Location:',1,0,'L',1);
$pdf->Cell(30,6,'Amount:',1,1,'L',1);
$current = $income['name'];
} /* END OF IF, LAST NAME IS NOT THE SAME WITH THE CURRENT NAME */
$pdf->SetTextColor (0,0,0);
$total = $income['samount'] + $income['prtamount'] + $income['faxamount'];
$name = $income['fname'] . ' ' .$income['lname'];
$signdate=phpdate($income['signstart']);
$pdf->Cell(30,6,$signdate,1,0,'L',0);
$pdf->Cell(70,6,$name,1,0,'L',0);
$pdf->Cell(70,6,$income['city'],1,0,'L',0);
$pdf->Cell(30,6,$total,1,1,'L',0);
} /* END OF FOREACH */
$pdf->Output();
?>
关于php - SetAutoPageBreak 不起作用或者我没有正确使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23463135/
SetAutoPageBreak 不起作用或者我没有正确使用它。它会在页脚之前停止第一页,但之后的每一页都只打印一行,再打印 39 页。我做错了什么。我找不到有关添加更多信息以使其正常工作的更多信息。
如果要启用它,如何在 fpdf 中使用 SetAutoPageBreak?在网上,我发现了各种变体: $p->SetAutoPageBreak(1,20); $p->SetAutoPageBreak(
我是一名优秀的程序员,十分优秀!