1
votes

I'm making a download of PDF with DOMPDF. Everything is working fine. The PDF is downloading and opens well in Adobe Reader. But at closing the window, Adobe Reader is asking me if I want to save the PDF file where I didn't change anything in. What is the possible problem that cause this problem?

$filename = $naam.' Factsheet.pdf';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();

file_put_contents('pdf/'.$filename, $dompdf->output( array("compress" => 0) ));

if ( !headers_sent() ) {
  $dompdf->stream($filename, $options);
}

Can please anybody help me with this problem?

2
Are you sure about the file path that you have given? try using custom file path file_put_contents('yourpath/Factsheet.pdf', $dompdf->output( array("compress" => 0) ));PHJCJO
The folder pdf/ exists in the root of my public_html. The folder also is writeable for the server and the PDF's are in the PDF folder on the server. That's is all working fine. But after download and opening the PDF. Adobe Reader is asking to save the changes to the PDF file while there is nothing changed after opening.Riagabel2
Is there any message(s) given by the adobe reader like repairing or something? when opening the pdf file?PHJCJO
Only a message after clicking close. It is asking if i want to save changes. I can choose yes, no or cancelRiagabel2
Almost certainly your PDF file is broken in some way and Adobe Reader is repairing it silently when opened. Because it's changed it then asks to save when closing. Can you post an example PDF file so that I can run it through a preflight tool?David van Driessche

2 Answers

1
votes

Sorry for grave digging, but i had the same issue, however i fixed my code but i dont know how, here is the working code

$filename = $sm_number . "_" . date('Ymd') .'_OK_CALCOOLING.pdf';


use Dompdf\Dompdf;

$dompdf = new Dompdf();
$dompdf->loadHtml($content);
$dompdf->setPaper('A4', 'portrait');
$dompdf->render();

$array = array(
    "compress" => 0,
    "Attachment" => 0
);


$dompdf->stream($filename, $array);
0
votes

Make sure you add ob_get_clean() when declaring your $html variable.

$html = ob_get_clean(); //ADD THIS LINE WHEN DECLARING HTML VARIABLE
$html .= 'My content here';

$dompdf = new Dompdf();
$dompdf->getOptions()->setIsFontSubsettingEnabled(true);
$dompdf->loadHtml(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));

$dompdf->setPaper('A4', 'portrait');
$dompdf->render();
$dompdf->stream("filename.pdf", array("compress" => 0, "Attachment" => false));
exit;