Blank PDF at live server but proper PDF rendered at local server

625 views
Skip to first unread message

Frank Staffas

unread,
Mar 24, 2019, 4:38:52 PM3/24/19
to dompdf
Hi,
The code below renders perfect PDFs at localhost but blank (empty) PDFs on live server. No errors:
"
ob_start();

//Set timezone
date_default_timezone_set("Europe/Stockholm");

// include autoloader
require_once '../dompdf/autoload.inc.php';

// reference the Dompdf namespace
use Dompdf\Dompdf;

//Fetch the class id from previous page
$class_id = filter_input(INPUT_GET,'class_id');
// instantiate and use the dompdf class
$dompdf = new DOMPDF();
$dompdf->set_option('enable_css_float', true);
$dompdf->set_option('isHtml5ParserEnabled', true);
$dompdf->set_option('enable_remote', true);

$my_path = 'localhost/CORS';

//Load file and get content from file
$file = 'http://'.$my_path.'/page.php?class_id='.$class_id;
$html = file_get_contents($file);

//Load html and render PDF
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream("FileName.pdf");

ob_end_flush();
"
What might be the problem here? Server checked for wrighting permissions and erorr logs.

BrianS

unread,
Mar 24, 2019, 5:04:57 PM3/24/19
to dompdf
So ... no error on the client or the server? And nothing in the logs?

You might try adding an `exit;` statement at the end of the script. It could be that the server is expecting more content and not yet streaming the content.

Frank Staffas

unread,
Mar 24, 2019, 5:56:57 PM3/24/19
to dompdf
That's right no errors and nothing in log according to support. "Exit" didn't make any difference I'm afraid.

Frank Staffas

unread,
Mar 27, 2019, 1:50:06 PM3/27/19
to dompdf
By changing from PHP 7 to PHP 5.5 the PDF rendering started to work again. As DomPDF supports PHP 7 I have no idea why.

BrianS

unread,
Jun 1, 2019, 10:12:01 AM6/1/19
to dompdf
That is an odd result. Maybe some error related to the specific version of Dompdf you're using? There were some incompatibilities with PHP 7 up until more recent versions of Dompdf. Anyway, glad you were able to find a "solution" (if not a great one).
Reply all
Reply to author
Forward
0 new messages