Using dompdf library generate the pdf file, while i opened that pdf file it shows failed to load content error. I set renderer path and renderer library given below.
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF; $rendererLibrary = 'dompdf.php'; $rendererLibraryPath = name(FILE).'/../dompdf/libraries/dompdf/'.$rendererLibrary;
Try this
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
$rendererLibrary = 'dompdf.php';
$rendererLibraryPath = dirname(__FILE__). 'libs/classes/dompdf' . $rendererLibrary;
Correct your PHP according to this
$file = "path_to_file";
$fp = fopen($file, "r") ;
header("Cache-Control: maxage=1");
header("Pragma: public");
header("Content-type: application/pdf");
header("Content-Disposition: inline; filename=".$myFileName."");
header("Content-Description: PHP Generated Data");
header("Content-Transfer-Encoding: binary");
header('Content-Length:' . filesize($file));
ob_clean();
flush();
while (!feof($fp)) {
$buff = fread($fp, 1024);
print $buff;
}
exit;
Just had a similar error today but not with PHPExcel.
I had to populate a PDF with PHP and show it after, but I was always getting a "Failed to load PDF document" error from Chrome.
I don't know if it was the same problem, but in my case, PHP was reporting Notice and Warning errors, nothing too important, but because of that, the PDF was not able to load. Hiding the error solved my problem!
TL;DR : Try error_reporting(E_STRICT);
on top of your PHP file (quick and dirty) or exit;
before reading the file so you can see the errors and fix them.