Answer the question
In order to leave comments, you need to log in
Blank screen when using dompdf: who faced?
I'm trying to generate a PDF from HTML using dompdf, but when I run the script, I see a blank page in the browser. Error output is enabled, but nothing is output.
Here is the code itself (using the example from the readme):
require_once '/var/www/tools/dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream();
$dompdf->stream('/var/www/hello.pdf');
$dompdf->set_option('isHtml5ParserEnabled', true);
Answer the question
In order to leave comments, you need to log in
Here are the docs https://github.com/dompdf/dompdf/wiki/Usage it clearly states:
The question arises: "What do you have in $_dompdf_warnings?"
And also what do you have in $dompdf->output ?
We need logos.
A white screen is normal, but you are streaming the file to the browser.
of course it didn’t help - if you take a minute and look into this very dompdf, you can find out what the stream function does
/**
* output the pdf code, streaming it to the browser
* the relevant headers are set so that hopefully the browser will recognise it
*/
function stream($options = '')
/**
* Returns the PDF as a string
*
* The file will open a download dialog by default. The options
* parameter controls the output. Accepted options are:
*
*
* 'compress' = > 1 or 0 - apply content stream compression, this is
* on (1) by default
*
*
* @param array $options options (see above)
*
* @return string
*/
public function output($options = null)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question