Problem with DOMPDF and Kohana 3
Posted
by alex
on Stack Overflow
See other posts from Stack Overflow
or by alex
Published on 2010-04-21T04:36:24Z
Indexed on
2010/04/21
4:43 UTC
Read the original article
Hit count: 572
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
© Stack Overflow or respective owner