File tree Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Expand file tree Collapse file tree 1 file changed +25
-7
lines changed Original file line number Diff line number Diff line change 29
29
*/
30
30
class MPDF extends AbstractRenderer implements WriterInterface
31
31
{
32
+ /**
33
+ * Overridden to set the correct includefile, only needed for MPDF 5
34
+ *
35
+ * @codeCoverageIgnore
36
+ * @param PhpWord $phpWord
37
+ */
32
38
public function __construct (PhpWord $ phpWord )
33
39
{
34
40
if (file_exists (Settings::getPdfRendererPath () . '/mpdf.php ' )) {
@@ -52,13 +58,8 @@ public function save($filename = null)
52
58
$ orientation = strtoupper ('portrait ' );
53
59
54
60
// Create PDF
55
- if ($ this ->includeFile != null ) {
56
- // MPDF version 5.*
57
- $ pdf = new \mpdf ();
58
- } else {
59
- // MPDF version > 6.*
60
- $ pdf = new \Mpdf \Mpdf ();
61
- }
61
+ $ mPdfClass = $ this ->getMPdfClassName ();
62
+ $ pdf = new $ mPdfClass ();
62
63
$ pdf ->_setPageSize ($ paperSize , $ orientation );
63
64
$ pdf ->addPage ($ orientation );
64
65
@@ -78,4 +79,21 @@ public function save($filename = null)
78
79
79
80
parent ::restoreStateAfterSave ($ fileHandle );
80
81
}
82
+
83
+ /**
84
+ * Return classname of MPDF to instantiate
85
+ *
86
+ * @codeCoverageIgnore
87
+ * @return string
88
+ */
89
+ private function getMPdfClassName ()
90
+ {
91
+ if ($ this ->includeFile != null ) {
92
+ // MPDF version 5.*
93
+ return '\mpdf ' ;
94
+ }
95
+
96
+ // MPDF version > 6.*
97
+ return '\Mpdf\Mpdf ' ;
98
+ }
81
99
}
You can’t perform that action at this time.
0 commit comments