From 0eb99d537d4179c7c4211600b58adb59d97f0d61 Mon Sep 17 00:00:00 2001 From: Sashi20 Date: Wed, 7 Aug 2019 12:36:30 +0530 Subject: Enable link to download certificate --- pdf/fpdf/tutorial/tuto5.php | 102 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 pdf/fpdf/tutorial/tuto5.php (limited to 'pdf/fpdf/tutorial/tuto5.php') diff --git a/pdf/fpdf/tutorial/tuto5.php b/pdf/fpdf/tutorial/tuto5.php new file mode 100755 index 0000000..f1b64a2 --- /dev/null +++ b/pdf/fpdf/tutorial/tuto5.php @@ -0,0 +1,102 @@ +Cell(40,7,$col,1); + $this->Ln(); + // Data + foreach($data as $row) + { + foreach($row as $col) + $this->Cell(40,6,$col,1); + $this->Ln(); + } +} + +// Better table +function ImprovedTable($header, $data) +{ + // Column widths + $w = array(40, 35, 40, 45); + // Header + for($i=0;$iCell($w[$i],7,$header[$i],1,0,'C'); + $this->Ln(); + // Data + foreach($data as $row) + { + $this->Cell($w[0],6,$row[0],'LR'); + $this->Cell($w[1],6,$row[1],'LR'); + $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R'); + $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R'); + $this->Ln(); + } + // Closing line + $this->Cell(array_sum($w),0,'','T'); +} + +// Colored table +function FancyTable($header, $data) +{ + // Colors, line width and bold font + $this->SetFillColor(255,0,0); + $this->SetTextColor(255); + $this->SetDrawColor(128,0,0); + $this->SetLineWidth(.3); + $this->SetFont('','B'); + // Header + $w = array(40, 35, 40, 45); + for($i=0;$iCell($w[$i],7,$header[$i],1,0,'C',true); + $this->Ln(); + // Color and font restoration + $this->SetFillColor(224,235,255); + $this->SetTextColor(0); + $this->SetFont(''); + // Data + $fill = false; + foreach($data as $row) + { + $this->Cell($w[0],6,$row[0],'LR',0,'L',$fill); + $this->Cell($w[1],6,$row[1],'LR',0,'L',$fill); + $this->Cell($w[2],6,number_format($row[2]),'LR',0,'R',$fill); + $this->Cell($w[3],6,number_format($row[3]),'LR',0,'R',$fill); + $this->Ln(); + $fill = !$fill; + } + // Closing line + $this->Cell(array_sum($w),0,'','T'); +} +} + +$pdf = new PDF(); +// Column headings +$header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)'); +// Data loading +$data = $pdf->LoadData('countries.txt'); +$pdf->SetFont('Arial','',14); +$pdf->AddPage(); +$pdf->BasicTable($header,$data); +$pdf->AddPage(); +$pdf->ImprovedTable($header,$data); +$pdf->AddPage(); +$pdf->FancyTable($header,$data); +$pdf->Output(); +?> -- cgit