I am trying to create a pdf document using the fpdf library with php, but I am getting an error in chrome like Failed to load PDF document. I can view the document correctly in firefox. Below is the code I'm trying to create pdf. Can anybody help? Thanks in advance.
<?php
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
ob_start();
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(40, 10, 'Hello World!');
header('Content-type: application/pdf');
header('Content-Transfer-Encoding: binary');
header("Content-Disposition: inline; filename='example2.pdf'");
$pdf->Output('example2.pdf', 'I');
ob_end_flush();
?>
source
share