Wednesday, January 18, 2012

DOMPDF stream() And output() Error PDF Code

Here the case that caused error

function pdf_create($html, $filename,$pass="nofmas", $stream=TRUE, $simpan =TRUE)
//  require_once("dompdf/");
if ($stream) {  
$dompdf = new DOMPDF();
$dompdf->set_paper("slip_gaji", "portrait");
 $dompdf->get_canvas()->get_cpdf()->setEncryption($pass, $pass, array('print'));
// simpan file
 $dompdf->get_canvas()->get_cpdf()->setEncryption($pass, $pass, array('print'));
 write_file("./invoices_temp/$filename.pdf", $dompdf->output());


The error hapen on streamed file but correct on stored file
"Acrobat reader could not open the file 'xxxxx.pdf' because it is either not a supported file or because the file has been damaged (for example it was sent as an email attachment and wasnt correctly decoded)."

The main problem actually on the PHP file. DOMPDF and PHP 5.3.

"Function set_magic_quotes_runtime() is deprecated"

Solved by this article

change the file
- class.pdf.php

like this attachment klik

Dikirim dari dengan dukungan dev-NET(system)