Hi
I need to generate six tables one by one but i am not able to generate with proper alignment its running out of page,I also checked pageheight,but its not working,My code is as follows and its very urgent some expert please hep me out in this issue.Thanks in advance
function BuildTable2($header2,$data2)
{
$this->SetFillColor(255,255,255);
$this->SetTextColor(0);
$this->SetDrawColor(0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
//Header
$w=array(20,20,40,18,50,12);
$this->SetFont('Arial','B',7);
for($i=0;$i<count($header2);$i++)
$this->Cell($w[$i],7,$header2[$i],1,0,'C',true);
$this->Ln();
//Color and font restoration
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('');
//Data
$fill=false;
$i = 0;
$x0=$x = $this->GetX();
$y = $this->GetY();
foreach($data2 as $row)
{
for ($i=0; $i<6; $i++) //Avoid very lengthy texts
{
$row[$i]=substr($row[$i],0,160);
}
$yH=9; //height of the row
//Issue a page break first if needed
$this->SetXY($x, $y);
$this->Cell($w[0], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x, $y);
$this->MultiCell($w[0],6,$row[0],0,'L');
$this->SetXY($x + $w[0], $y);
$this->Cell($w[1], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x + $w[0], $y);
$this->MultiCell($w[1],4,$row[1],0,'L');
$x =$x+$w[0];
$this->SetXY($x + $w[1], $y);
$this->Cell($w[2], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x + $w[1], $y);
$this->MultiCell($w[2],5,$row[2],0,'L');
$x =$x+$w[1];
$this->SetXY($x + $w[2], $y);
$this->Cell($w[3], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x + $w[2], $y);
$this->MultiCell($w[3],6,$row[3],0,'L');
$x =$x+$w[2];
$this->SetXY($x + $w[3], $y);
$this->Cell($w[4], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x + $w[3], $y);
$this->MultiCell($w[4],6,$row[4],0,'L');
$x =$x+$w[3];
$this->SetXY($x + $w[4], $y);
$this->Cell($w[5], $yH, "", 'LRB',0,'',$fill);
$this->SetXY($x + $w[4], $y);
$this->MultiCell($w[5],6,$row[5],0,'L');
$y=$y+$yH; //move to next row
$x=$x0; //start from firt column
}
}
$pdf=new PDF();
$pdf->Addpage();
$page_height = 300;
$bottom_margin = 20;
$yH=12;
$pdf->SetAutoPageBreak(auto,false);
//Second Table
$j=0;
$i=1;
if (count($data2)!=0)
{
foreach ($data2 as $row)
{
$pagedata[$j]=$row;
if ((count($data2)<=20 && $i== count($data2)))
{
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->SetXY($x,$y+10);
$pdf->SetFont('Arial','B',7);
$pdf->cell(10,10,"Research Scholars(C - Current, P - Graduated)",0,0);
$pdf->SetXY($x,$y+20);
$space_left = $page_height - $pdf->GetY(); // space left on page
$space_left -= $bottom_margin; // less the bottom margin
if ($yH >= $space_left)
{
$pdf->Ln(5);
$pdf->AddPage(); // page break
}
$pdf->BuildTable2($header2,$pagedata);
$j=0;
$pagedata="";
}
if (($i%20)==0)
{
$pdf->AddPage();
if($i==20)
{
$x1=$pdf->GetX();
$y1=$pdf->GetY();
$pdf->SetXY($x1,$y1+10);
$pdf->SetFont('Arial','B',7);
$pdf->cell(10,10,"Research Scholars(C - Current, P - Graduated)",0,0);
$x2=$pdf->GetX();
$y2=$pdf->GetY();
$pdf->SetXY($x2,$y2+10);
$space_left = $page_height - $pdf->GetY(); // space left on page
$space_left -= $bottom_margin; // less the bottom margin
if ($yH >= $space_left)
{
$pdf->Ln(5);
$pdf->AddPage(); // page break
}
$pdf->BuildTable3($header3,$pagedata);
$j=0;
$pagedata="";
}
}
if((count($data2)>20) && $i==count($data2) && ($i%20) !=0)
{
$pdf->AddPage();
$pdf->BuildTable2($header2,$pagedata);
$j=0;
$pagedata="";
}
$i++;
$j++;
}
}