当我运行这个程序时,在正确显示Page1之后,它会为每个单元格创建一个单独的页面,对于row6的结果,当应该只有2个页面时,创建另外5个页面。它将为5个单元格创建5个页面。
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,10,30);
// Arial bold 15
$this->SetFont('Times','B',15);
// Move to the right
$this->Cell(30,30);
// Title
$this->Cell(0,10,'Austin Grammar School',0,1,'L');
$this->SetFont('Arial','i',10);
$this->Cell(90,0,'136 - E, Austin.',0,1,'R');
$this->SetFont('Arial','U',10);
$this->Cell(0,20,'Academic Report',0,1,'C');
$this->SetFont('Arial',null,10);
$this->Cell(0,-10,'First Term : 2014-2015',0, 1 ,'C');
$this->Rect(10,40,190,10);
$this->SetFont('Arial',null,10);
//Student Name
$this->SetFont('Times','',12);
$this->Cell(0,25,'Student Name :',0, 0,'L');
$this->SetFont('Arial','B',10);
$this->Cell(-120,25,'Mr. Abc (2014-353-10)',0, 0,'R');
$this->Ln(5);
//Address
$this->SetFont('Times',null,10);
$this->Cell(0,25,'Address :',0, 0,'L');
$this->SetFont('Arial','B',10);
$this->Cell(-120,25,'174-XX PA',0, 0,'R');
//DoB
$this->SetFont('Arial',null,10);
$this->Cell(88,15,'DOB :',0, 0,'R');
$this->SetFont('Arial','B',10);
$this->Cell(0,15,'20-Oct-1986',0, 0,'L');
$this->ln(5);
//Grade
$this->SetFont('Arial',null,10);
$this->Cell(160,15,'Grade :',0, 0,'R');
$this->SetFont('Arial','B',10);
$this->Cell(0,15,'X',0, 0,'L');
//section
$this->SetFont('Arial',null,10);
$this->Cell(-10,15,'Section :',0, 0,'R');
$this->SetFont('Arial','B',10);
$this->Cell(0,15,'X-ZA',0, 0,'L');
// Line break
// Grading Table
$this->SetXY(145,10);
$this->SetFont('Times','B',8);
$this->Cell(55,3,"Grading Scheme",1,1,'C');
$this->SetFont('Times',null,7);
$this->SetXY(145,13);
$this->Cell(10,3,"A+",'LRB',1,'C');
$this->SetXY(145,16);
$this->Cell(10,3,"A",'LRB',1,'C');
$this->SetXY(145,19);
$this->Cell(10,3,"B",'LRB',1,'C');
$this->SetXY(145,22);
$this->Cell(10,3,"C",'LRB',1,'C');
$this->SetXY(145,25);
$this->Cell(10,3,"D",'LRB',1,'C');
$this->SetXY(145,28);
$this->Cell(10,3,"U",'LRB',1,'C');
$this->SetXY(155,13);
$this->Cell(15,3,"Humanities",'RB',1,'C');
$this->SetXY(155,16);
$this->Cell(15,3,"85-100",'RB',1,'C');
$this->SetXY(155,19);
$this->Cell(15,3,"80-84",'RB',1,'C');
$this->SetXY(155,22);
$this->Cell(15,3,"70-79",'RB',1,'C');
$this->SetXY(155,25);
$this->Cell(15,3,"60-69",'RB',1,'C');
$this->SetXY(155,28);
$this->Cell(15,3,"0-60",'RB',1,'C');
$this->SetXY(170,13);
$this->Cell(15,3,"Sciences",'RB',1,'C');
$this->SetXY(170,16);
$this->Cell(15,3,"85-100",'RB',1,'C');
$this->SetXY(170,19);
$this->Cell(15,3,"80-84",'RB',1,'C');
$this->SetXY(170,22);
$this->Cell(15,3,"70-79",'RB',1,'C');
$this->SetXY(170,25);
$this->Cell(15,3,"60-69",'RB',1,'C');
$this->SetXY(170,28);
$this->Cell(15,3,"0-60",'RB',1,'C');
$this->SetXY(185,13);
$this->Cell(15,3,"Sciences",'RB',1,'C');
$this->SetXY(185,16);
$this->Cell(15,3,"85-100",'RB',1,'C');
$this->SetXY(185,19);
$this->Cell(15,3,"80-84",'RB',1,'C');
$this->SetXY(185,22);
$this->Cell(15,3,"70-79",'RB',1,'C');
$this->SetXY(185,25);
$this->Cell(15,3,"60-69",'RB',1,'C');
$this->SetXY(185,28);
$this->Cell(15,3,"0-60",'RB',1,'C');
$this->Ln(24);
//Full Page Blue Border
$this->SetLineWidth(1);
$this->SetDrawColor(0,0,135);
$this->Rect(5,5,200,285);
$this->SetFont('Arial','B',10);
}
}
$pdf = new PDF();
$header=array('Subject','October Test ','December Exam','Remarks');
//Data loading
$pdf->AliasNbPages();
$pdf->AddPage();
//~~~~~~~~~~~~~ Table Header ~~~~~~~~~~
$pdf->Cell(40,20,'Subject','LT',0,'C',0);
$pdf->Cell(75,10,'First Term',1,1,'C',0);
$pdf->Cell(40,10,'','LRB',0,'C',0);
$pdf->SetFont('Arial','',9);
$pdf->Cell(25,10,'October Test','TB',0,'C',0);
$pdf->Cell(25,10,'December Exam',1,0,'C',0);
$pdf->Cell(25,10,'Term Average',1,0,'C',0);
$pdf->SetXY(125,55);
$pdf->Cell(75,20,'Teacher\'s Evaluation','TRB',0,'C',0);
//----- table Content-----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,75);
$pdf->Cell(40,40,'Biology','LRB',0,'C',0);
$pdf->SetXY(50,75);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,75);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,75);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,75);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//----- Row 2-----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,115);
$pdf->Cell(40,40,'Geography','LRB',0,'C',0);
$pdf->SetXY(50,115);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,115);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,115);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,115);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//----- Row 3-----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,155);
$pdf->Cell(40,40,'Food & Nutrition','LRB',0,'C',0);
$pdf->SetXY(50,155);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,155);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,155);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,155);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//----- Row 4 -----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,195);
$pdf->Cell(40,40,'Economics','LRB',0,'C',0);
$pdf->SetXY(50,195);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,195);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,195);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,195);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//----- Row 5 -----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,235);
$pdf->Cell(40,40,'English language','LRB',0,'C',0);
$pdf->SetXY(50,235);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,235);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,235);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,235);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//----- Row 6 -----
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,275);
$pdf->Cell(40,40,'English language','LRB',0,'C',0);
$pdf->SetXY(50,275);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,275);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,275);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,275);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');
//-- Show Output --------
$pdf->Output();
?>
答案 0 :(得分:1)
在每5行之后,使用单独的函数在每个页面中添加Table标题,并在每个页面中仅添加5行。并重复与第一页相同的XY坐标。
//----- Row 6 -----
//Next page Header(Better create a function for this)
$pdf->AddPage();
$pdf->Cell(40,20,'Subject','LT',0,'C',0);
$pdf->Cell(75,10,'First Term',1,1,'C',0);
$pdf->Cell(40,10,'','LRB',0,'C',0);
$pdf->SetFont('Arial','',9);
$pdf->Cell(25,10,'October Test','TB',0,'C',0);
$pdf->Cell(25,10,'December Exam',1,0,'C',0);
$pdf->Cell(25,10,'Term Average',1,0,'C',0);
$pdf->SetXY(125,55);
$pdf->Cell(75,20,'Teacher\'s Evaluation','TRB',0,'C',0);
// Row 6 content
$pdf->SetFont('Arial','',10);
$pdf->SetXY(10,75);
$pdf->Cell(40,40,'English language','LRB',0,'C',0);
$pdf->SetXY(50,75);
$pdf->Cell(25,40,'77','RB',0,'C',0);
$pdf->SetXY(75,75);
$pdf->Cell(25,40,'87','RB',0,'C',0);
$pdf->SetXY(100,75);
$pdf->Cell(25,40,'82','RB',0,'C',0);
$pdf->SetXY(125,75);
$pdf->MultiCell(75,10,'dg,lfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwoblfnmdonjfgdnolfdsfsgnonwedwdfwf wrfw wrfwfw wfwf wfwfwfw fwfwfwfw wwob','TRB','L');