File tree Expand file tree Collapse file tree 4 files changed +40
-4
lines changed Expand file tree Collapse file tree 4 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,7 @@ public function __call($function, $args)
109
109
} else {
110
110
// All other elements
111
111
array_unshift ($ args , $ element ); // Prepend element name to the beginning of args array
112
+
112
113
return call_user_func_array (array ($ this , 'addElement ' ), $ args );
113
114
}
114
115
}
Original file line number Diff line number Diff line change @@ -35,6 +35,16 @@ class DomPDF extends AbstractRenderer implements WriterInterface
35
35
*/
36
36
protected $ includeFile = null ;
37
37
38
+ /**
39
+ * Gets the implementation of external PDF library that should be used.
40
+ *
41
+ * @return Dompdf implementation
42
+ */
43
+ protected function createExternalWriterInstance ()
44
+ {
45
+ return new DompdfLib ();
46
+ }
47
+
38
48
/**
39
49
* Save PhpWord to file.
40
50
*
@@ -49,7 +59,7 @@ public function save($filename = null)
49
59
$ orientation = 'portrait ' ;
50
60
51
61
// Create PDF
52
- $ pdf = new DompdfLib ();
62
+ $ pdf = $ this -> createExternalWriterInstance ();
53
63
$ pdf ->setPaper (strtolower ($ paperSize ), $ orientation );
54
64
$ pdf ->loadHtml (str_replace (PHP_EOL , '' , $ this ->getContent ()));
55
65
$ pdf ->render ();
Original file line number Diff line number Diff line change @@ -44,6 +44,18 @@ public function __construct(PhpWord $phpWord)
44
44
parent ::__construct ($ phpWord );
45
45
}
46
46
47
+ /**
48
+ * Gets the implementation of external PDF library that should be used.
49
+ *
50
+ * @return Mpdf implementation
51
+ */
52
+ protected function createExternalWriterInstance ()
53
+ {
54
+ $ mPdfClass = $ this ->getMPdfClassName ();
55
+
56
+ return new $ mPdfClass ();
57
+ }
58
+
47
59
/**
48
60
* Save PhpWord to file.
49
61
*
@@ -58,8 +70,7 @@ public function save($filename = null)
58
70
$ orientation = strtoupper ('portrait ' );
59
71
60
72
// Create PDF
61
- $ mPdfClass = $ this ->getMPdfClassName ();
62
- $ pdf = new $ mPdfClass ();
73
+ $ pdf = $ this ->createExternalWriterInstance ();
63
74
$ pdf ->_setPageSize ($ paperSize , $ orientation );
64
75
$ pdf ->addPage ($ orientation );
65
76
Original file line number Diff line number Diff line change @@ -36,6 +36,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
36
36
*/
37
37
protected $ includeFile = 'tcpdf.php ' ;
38
38
39
+ /**
40
+ * Gets the implementation of external PDF library that should be used.
41
+ *
42
+ * @param string $orientation Page orientation
43
+ * @param string $unit Unit measure
44
+ * @param string $paperSize Paper size
45
+ *
46
+ * @return \TCPDF implementation
47
+ */
48
+ protected function createExternalWriterInstance ($ orientation , $ unit , $ paperSize )
49
+ {
50
+ return new \TCPDF ($ orientation , $ unit , $ paperSize );
51
+ }
52
+
39
53
/**
40
54
* Save PhpWord to file.
41
55
*
@@ -50,7 +64,7 @@ public function save($filename = null)
50
64
$ orientation = 'P ' ;
51
65
52
66
// Create PDF
53
- $ pdf = new \ TCPDF ($ orientation , 'pt ' , $ paperSize );
67
+ $ pdf = $ this -> createExternalWriterInstance ($ orientation , 'pt ' , $ paperSize );
54
68
$ pdf ->setFontSubsetting (false );
55
69
$ pdf ->setPrintHeader (false );
56
70
$ pdf ->setPrintFooter (false );
You can’t perform that action at this time.
0 commit comments