} public function ColoredTable($header, $data) { $this->SetFillColor(224, 235, 255); $this->SetTextColor(0); $this->SetFont(''); $w = array(40, 35, 40, 45); $fill = 0; 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; } $this->Cell(array_sum($w), 0, '', 'T'); } } $pdf = new Principal('L', PDF_UNIT, 'Legal', true, 'UTF-8', false); $pdf->SetFont('times', 'BI', 12); $pdf->AddPage(); $header = array('Country', 'Capital', 'Area (sq km)', 'Pop. (thousands)'); $data = $pdf->LoadData($ruta . '\\table_data_demo.php'); $pdf->ColoredTable($header, $data); $pdf->lastPage(); $pdf->Output('ejercicio1.pdf', 'D'); exit; ?>