File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -99,6 +99,13 @@ class Settings
9999 */
100100 private static $ pdfRendererPath = null ;
101101
102+ /**
103+ * Config to the external Library used for rendering PDF files
104+ *
105+ * @var string
106+ */
107+ private static $ pdfRendererConfig = null ;
108+
102109 /**
103110 * Measurement unit
104111 *
@@ -230,6 +237,19 @@ public static function setPdfRendererName($libraryName)
230237 return true ;
231238 }
232239
240+ /**
241+ * Set the config to use for the PDF Rendering Library.
242+ *
243+ * @param array $libraryConfig
244+ * @return string
245+ */
246+ public static function setPdfRendererConfig ($ libraryConfig )
247+ {
248+ self ::$ pdfRendererConfig = $ libraryConfig ;
249+
250+ return true ;
251+ }
252+
233253 /**
234254 * Return the directory path to the PDF Rendering Library.
235255 *
@@ -240,6 +260,16 @@ public static function getPdfRendererPath()
240260 return self ::$ pdfRendererPath ;
241261 }
242262
263+ /**
264+ * Return the config to instantiate PDF Rendering Library.
265+ *
266+ * @return array
267+ */
268+ public static function getPdfRendererConfig ()
269+ {
270+ return self ::$ pdfRendererConfig ;
271+ }
272+
243273 /**
244274 * Location of external library to use for rendering PDF files
245275 *
Original file line number Diff line number Diff line change 2929 */
3030class MPDF extends AbstractRenderer implements WriterInterface
3131{
32+ const MPDF_5 = '\mpdf ' ;
33+ const MPDF_6 = '\Mpdf\Mpdf ' ;
34+
3235 /**
3336 * Overridden to set the correct includefile, only needed for MPDF 5
3437 *
@@ -59,7 +62,12 @@ public function save($filename = null)
5962
6063 // Create PDF
6164 $ mPdfClass = $ this ->getMPdfClassName ();
62- $ pdf = new $ mPdfClass ();
65+ if (self ::MPDF_5 === $ mPdfClass ) {
66+ $ pdf = new $ mPdfClass ();
67+ } else {
68+ $ mPdfConfig = Settings::getPdfRendererConfig () ?: array ();
69+ $ pdf = new $ mPdfClass ($ mPdfConfig );
70+ }
6371 $ pdf ->_setPageSize ($ paperSize , $ orientation );
6472 $ pdf ->addPage ($ orientation );
6573
@@ -90,10 +98,10 @@ private function getMPdfClassName()
9098 {
9199 if ($ this ->includeFile != null ) {
92100 // MPDF version 5.*
93- return ' \mpdf ' ;
101+ return self :: MPDF_5 ;
94102 }
95103
96104 // MPDF version > 6.*
97- return ' \Mpdf\Mpdf ' ;
105+ return self :: MPDF_6 ;
98106 }
99107}
You can’t perform that action at this time.
0 commit comments