Я использую FPDF для создания PDF для меня, используя данные SQL.Казалось, все это работает, потому что я тестировал это в Edge.Позже я попытался открыть PDF-файл, сгенерированный в Chrome, но получил следующую ошибку: Не удается загрузить PDF-документ.Эта ошибка не всплыла в краю или сафари.PDF загрузился и выглядел именно так, как я хотел.Почему это происходит?
Примечание. Я использую JQuery Mobile для этого сайта.
<?php
ob_start();
//call the FPDF library
require('fpdfmap/fpdf.php');
//A4 width : 219mm
//default margin : 10mm each side
//writable horizontal : 219-(10*2)=189mm
//create pdf object
$pdf = new FPDF('P','mm','A4');
//add new page
$pdf->AddPage();
//set font to arial, bold, 14pt
$pdf->SetFont('Arial','B',14);
//Cell(width , height , text , border , end line , [align] )
$pdf->Cell(130 ,5,'HONDENSECTIE',0,0);
$pdf->Cell(59 ,5,'RAPPORTAGES',0,1,'R');//end of line
//make a dummy empty cell as a vertical spacer
$pdf->Cell(189 ,10,'',0,1);//end of line
$pdf->SetFont('Arial','B',12);
$pdf->Cell(189 ,5,'Rapportages',1,0);
$pdf->Cell(189 ,10,'',0,1);//end of line
$query = "SELECT * FROM rapportages INNER JOIN users ON users.username = rapportages.gebruikersid ORDER BY datum";
$stm = $con->prepare($query);
$stm->execute();
$result = $stm->fetchAll(PDO::FETCH_OBJ);
foreach ($result as $pers) {
//invoice contents
$pdf->SetFont('Arial','B',12);
$pdf->Cell(48 ,5,'Naam',1,0);
$pdf->Cell(47 ,5,'Tijdzone',1,0);
$pdf->Cell(47 ,5,'Locatie',1,0);
$pdf->Cell(47 ,5,'Datum',1,1);
$pdf->SetFont('Arial','',12);
$pdf->Cell(48 ,5,$pers->name,1,0);
$pdf->Cell(47 ,5,$pers->tijdzone,1,0);
$pdf->Cell(47 ,5,$pers->locatie,1,0);
$pdf->Cell(47 ,5,$pers->datum,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Onderdeel',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->onderdeel,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Weer',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->weer,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Omstandigheden',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->omstandigheden,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Opdracht',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->opdracht,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'POC',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->poc,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Telefoonnummer',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->telefoon,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Team 1',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->team1,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Team 2',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->team2,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Team 3',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->team3,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Team 4',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->team4,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Bijzonderheden',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->bijzonderheden,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Aanbevelingen',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->aanbevelingen,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Conclusie',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->conclusie,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Opmerking',1,0);
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->opmerking,1,1);
$pdf->SetFont('Arial','B',12);
$pdf->Cell(40 ,5,'Status',1,0);//end of line
$pdf->SetFont('Arial','',12);
$pdf->Cell(149 ,5,$pers->status,1,1);
$pdf->Cell(189 ,10,'',0,1);//end of line
}
//output the result
$pdf->Output('D','rapportages.pdf');
ob_end_flush();
?>
Если мне нужно больше информации, дайте мне знать.