I have used DOMPDF many times before successfully, however outside of the Kohana Framework.
I created a module for DOMPDF and called it simply pdf. Here is it's code.
class Pdf {
private $domPdfInstance;
public function __construct($html) {
if ( ! class_exists('DOMPDF', FALSE)) {
// Load DOMPDF
require Kohana::find_file('vendor', 'dompdf/dompdf_config.inc');
}
$this->domPdfInstance = new DOMPDF;
$this->domPdfInstance->load_html($html);
}
public function render() {
$this->domPdfInstance->render();
return $this;
}
public function stream($filename) {
if (pathinfo($filename, PATHINFO_EXTENSION) !== 'pdf') {
$filename .= '.pdf';
}
$this->domPdfInstance->stream($filename);
return $this;
}
}
For some reason, any PDF I generate using this results in it being corrupt (not opening under Mac OS X's Preview app at least).
I have even tried this basic HTML
<html>
<head>
<title>PDF</title>
</head>
<body>
please work
</body>
</html>
Is this a known problem? I have not touched anything in dompdf_config.inc.php
except uncomment out the error reporting levels so they now read
error_reporting(E_STRICT | E_ALL);
PHP is not reporting any errors.
Here is a screenshot of the error from Preview (though I think it's probably unhelpful)
Some thing I have thought may be a problem
- Auto loading conflicts
- Base path conflicts
This forum thread also looks interesting.
Update
I have tried replacing the auto load stuff like from within the forum, but it still doesn't seem to work for me.
Another Update
I just opened the PDF file, and here are the contents...
<html> <head> <title>PDF</title> </head> <body> yo </body> </html> %PDF-1.3 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R
/OpenAction 8 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R ] /Count 1 /Resources << /ProcSet 4 0 R /Font << /F1 9 0 R
>
/MediaBox [0.000 0.000 612.000 792.000] endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Creator (dompdf) /CreationDate (D:20100421145253+10'00') /ModDate (D:20100421145253+10'00') endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents 7 0 R endobj 7 0 obj << /Filter /FlateDecode /Length 60 >> stream xœã2Ð300P@&‹Ò¹œBÌÀlssS=##…}7CC#=…4Ê|M…,×�¯o Ô endstream endobj 8 0 obj [6 0 R /Fit] endobj 9 0 obj
<< /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Times-Roman /Encoding /WinAnsiEncoding
endobj xref 0 10 0000000000 65535 f 0000000008 00000 n 0000000091 00000 n 0000000137 00000 n 0000000291 00000 n 0000000320 00000 n 0000000434 00