Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- # using last version of FPDF 1.7: http://www.fpdf.org/
- require_once './fpdf17/fpdf.php';
- class PDF extends FPDF
- {
- public 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
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement