2525
2626class PdfRenderer implements Renderer
2727{
28- private $ paperSize = '8x11 ' ;
29- private $ paperOrientation = 'portrait ' ;
30- private $ basePath = '/ ' ;
31- private $ fileName = null ;
3228 private $ resolver = null ;
3329 private $ htmlRenderer = null ;
3430
@@ -43,39 +39,6 @@ public function getHtmlRenderer()
4339 return $ this ->htmlRenderer ;
4440 }
4541
46- public function setPaperSize ($ size )
47- {
48- $ this ->paperSize = $ size ;
49-
50- return $ this ;
51- }
52-
53- public function setPaperOrientation ($ orientation )
54- {
55- $ this ->paperOrientation = $ orientation ;
56-
57- return $ this ;
58- }
59-
60- public function setBasePath ($ path )
61- {
62- $ this ->path = $ path ;
63-
64- return $ this ;
65- }
66-
67- public function setFileName ($ name )
68- {
69- $ this ->fileName = $ name ;
70-
71- return $ this ;
72- }
73-
74- public function getFileName ()
75- {
76- return $ this ->fileName ;
77- }
78-
7942 /**
8043 * Renders values as a PDF
8144 *
@@ -87,13 +50,17 @@ public function render($nameOrModel, $values = null)
8750 {
8851 $ html = $ this ->getHtmlRenderer ()->render ($ nameOrModel , $ values );
8952
53+ $ paperSize = $ nameOrModel ->getOption ('paperSize ' );
54+ $ paperOrientation = $ nameOrModel ->getOption ('paperOrientation ' );
55+ $ basePath = $ nameOrModel ->getOption ('basePath ' );
56+
9057 $ pdf = new DOMPDF ();
91- $ pdf ->set_paper ($ this -> paperSize , $ this -> paperOrientation );
92- $ pdf ->set_base_path ($ this -> basePath );
58+ $ pdf ->set_paper ($ paperSize , $ paperOrientation );
59+ $ pdf ->set_base_path ($ basePath );
9360
9461 $ pdf ->load_html ($ html );
9562 $ pdf ->render ();
96-
63+
9764 return $ pdf ->output ();
9865 }
9966
0 commit comments