1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 | <?php
class PdfHelper extends AppHelper {
var $helpers = array('Html');
var $lib = null;
function __construct() {
parent::__construct();
App::import('Vendor','DOMPDF',array('file' => 'dompdf/dompdf_config.inc.php'));
$this->lib = new DOMPDF();
}
function load_html($html) {
$this->lib->load_html($html);
}
function set_paper($size='A4',$orientation='portrait') {
$this->lib->set_paper($size,$orientation);
}
function render() {
$this->lib->render();
}
function stream($name) {
$this->lib->stream($name,array("Attachment" => 0));
}
function css($path, $rel = null, $htmlAttributes = array(),$inline=true) {
$link = $this->Html->css($path,$rel,$htmlAttributes);
$link = preg_replace('/href=\"/','href="http://'.env('HTTP_HOST'),$link);
if(!$inline) {
$view =& ClassRegistry::getObject('view');
$view->addScript($link);
}
else
return $link;
}
function image($path,$options=array()) {
$img = $this->Html->image($path,$options);
return preg_replace('/src=\"/','src="http://'.env('HTTP_HOST'),$img);
}
}
?> |
|---|