I have a page that requires the generation of PDF reports to show data from a MySQL database, I use the FPDF library. When I generate them in local I work perfectly but when I upload it Hostinger nothing is generated, I download the pdf file but Adobe shows me a warning that the file was not decompressed.
Annex the code of one of the reports to see what they think. I appreciate the help in advance.
<?php
header("Content-Type: text/html; charset=UTF-8");
require('../../lib/fpdf/fpdf.php');
date_default_timezone_set('America/Mexico_City');
class PDF extends FPDF {
//cabecera de la pagina
function Header(){
global $title;
//Arial bold 15
$this->setFont('Arial','B',15);
//calculamos ancho y posicion del titulo
$w = $this->GetStringWidth($title)+6;
$this->SetX((308-$w)/2);
//colores de los bordes, fondo y texto
$this->SetDrawColor(0,80,180);
$this->SetFillColor(230,230,0);
$this->SetTextColor(220,50,50);
//ancho del borde (1mm);
$this->SetLineWidth(1);
//titulo
$this->Cell($w,9,$title,1,1,'C',true);
//salto de linea
$this->Ln(6);
//Logo
$this->Image('../img/urss_mapa.png',10,8,33);
//Arial bold 15
$this->SetFont('Arial','B',15);
//Movernos a la derecha
$this->Cell(70);
//titulo
$this->Cell(148,10,'Obras en proceso',1,0,'C');
$this->setFont('Arial','B',10);
$this->Cell(15);
$time = time();
$this->Cell(50,10,'Fecha: '.date('d-m-Y (H:i:s)',$time).'',0);
//salto de linea
$this->Ln(17);
}
//pie de pagina
function Footer(){
//posicion a 1,5 cm del final
$this->SetY(-15);
//Arial italic 8
$this->SetFont('Arial','I',8);
//numero de la pagina
$this->Cell(0,10,'Pag. '.$this->PageNo().'/{nb}',0,0,'C');
}
function cargarDatos(){
require_once '../conexionOO.php';
$query = "SELECT DISTINCT obras.Nombre, Descripcion,FechaEntrega, Costo, Estatus FROM obras, avances_de_obra, obras_terminadas WHERE obras.Folio=avances_de_obra.Folio AND Estatus='inconclusa' AND obras_terminadas.Folio!=obras.Folio ";
$result = $conn->query($query) or die($conn->error._LINE_);
//colores, ancho de linea y fuente en negrita
$this->SetFillColor(255,0,0);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('Arial','B',12);
//Anchura de las columnas
$w = array(80,90,30,28,30);
//titulos de las columnas
$this->Cell(10);
$titulosColumnas = array('Nombre','Descripcion','Entrega','Costo','Estatus');
for($i=0; $i<count($titulosColumnas);$i++)
$this->Cell($w[$i],4,$titulosColumnas[$i],1,0,'C',true);
$this->Ln();
//Restauracion de colores y fuentes
$this->SetFillColor(224,235,255);
$this->SetTextColor(0);
$this->SetFont('Arial','',10);
//Datos
$fill = false;
if($result->num_rows > 0){
while($row = $result->fetch_assoc()){
$this->Cell(10);
$this->Cell($w[0],6,$row["Nombre"],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row["Descripcion"],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row["FechaEntrega"],'LR',0,'L',$fill);
$this->Cell($w[3],6,$row["Costo"],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row["Estatus"],'LR',0,'L',$fill);
$this->Ln();
$fill = !$fill;
}
//linea de cierre
$this->Cell(10);
$this->Cell(array_sum($w),0,'','T');
}
}
}
//creacion del objeto de la clase heredada
$pdf = new PDF('L','mm','A4');
$title = 'Construc-toro Max';
$pdf->SetTitle($title);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$pdf->cargarDatos();
$pdf->Output();
? >