File tree Expand file tree Collapse file tree 2 files changed +40
-3
lines changed Expand file tree Collapse file tree 2 files changed +40
-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 ' ;
3234 /**
3335 * Overridden to set the correct includefile, only needed for MPDF 5
3436 *
@@ -59,7 +61,12 @@ public function save($filename = null)
5961
6062 // Create PDF
6163 $ mPdfClass = $ this ->getMPdfClassName ();
62- $ pdf = new $ mPdfClass ();
64+ if (self ::MPDF_5 === $ mPdfClass ) {
65+ $ pdf = new $ mPdfClass ();
66+ } else {
67+ $ mPdfConfig = Settings::getPdfRendererConfig () ?: [];
68+ $ pdf = new $ mPdfClass ($ mPdfConfig );
69+ }
6370 $ pdf ->_setPageSize ($ paperSize , $ orientation );
6471 $ pdf ->addPage ($ orientation );
6572
@@ -90,10 +97,10 @@ private function getMPdfClassName()
9097 {
9198 if ($ this ->includeFile != null ) {
9299 // MPDF version 5.*
93- return ' \mpdf ' ;
100+ return self :: MPDF_5 ;
94101 }
95102
96103 // MPDF version > 6.*
97- return ' \Mpdf\Mpdf ' ;
104+ return self :: MPDF_6 ;
98105 }
99106}
You can’t perform that action at this time.
0 commit comments