22
33namespace LaravelDaily \Invoices ;
44
5- use Barryvdh \DomPDF \Facade \Pdf ;
5+ use Barryvdh \DomPDF \Facade \Pdf as PDF ;
66use Carbon \Carbon ;
77use Exception ;
88use Illuminate \Http \Response ;
@@ -131,7 +131,7 @@ class Invoice
131131 public $ table_columns ;
132132
133133 /**
134- * @var Pdf
134+ * @var PDF
135135 */
136136 public $ pdf ;
137137
@@ -150,6 +150,11 @@ class Invoice
150150 */
151151 protected array $ paperOptions ;
152152
153+ /**
154+ * @var array
155+ */
156+ protected $ options ;
157+
153158 /**
154159 * Invoice constructor.
155160 *
@@ -189,9 +194,12 @@ public function __construct($name = '')
189194 $ this ->currency_thousands_separator = config ('invoices.currency.thousands_separator ' );
190195 $ this ->currency_format = config ('invoices.currency.format ' );
191196
192- //Paper
197+ // Paper
193198 $ this ->paperOptions = config ('invoices.paper ' );
194199
200+ // DomPDF options
201+ $ this ->options = config (['invoices.dompdf_options ' ]) ?? ['enable_php ' => true ];
202+
195203 $ this ->disk = config ('invoices.disk ' );
196204 $ this ->table_columns = static ::TABLE_COLUMNS ;
197205 }
@@ -265,7 +273,9 @@ public function render()
265273 $ view = View::make ($ template , ['invoice ' => $ this ]);
266274 $ html = mb_convert_encoding ($ view , 'HTML-ENTITIES ' , 'UTF-8 ' );
267275
268- $ this ->pdf = Pdf::setOption (['enable_php ' => true ])->setPaper ($ this ->paperOptions ['size ' ], $ this ->paperOptions ['orientation ' ])->loadHtml ($ html );
276+ $ this ->pdf = PDF ::setOptions ($ this ->options )
277+ ->setPaper ($ this ->paperOptions ['size ' ], $ this ->paperOptions ['orientation ' ])
278+ ->loadHtml ($ html );
269279 $ this ->output = $ this ->pdf ->output ();
270280
271281 return $ this ;
0 commit comments