Skip to content

Commit d626098

Browse files
authored
Allow to redefine TCPDF object
Sometimes we need create TCPDF object with modified initial arguments. This change allow rewrite only createExternalWriterInstance() in user defined TCPDF class.
1 parent 21f4bb3 commit d626098

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/PhpWord/Writer/PDF/TCPDF.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
3636
*/
3737
protected $includeFile = 'tcpdf.php';
3838

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+
3953
/**
4054
* Save PhpWord to file.
4155
*
@@ -50,7 +64,7 @@ public function save($filename = null)
5064
$orientation = 'P';
5165

5266
// Create PDF
53-
$pdf = new \TCPDF($orientation, 'pt', $paperSize);
67+
$pdf = $this->createExternalWriterInstance($orientation, 'pt', $paperSize);
5468
$pdf->setFontSubsetting(false);
5569
$pdf->setPrintHeader(false);
5670
$pdf->setPrintFooter(false);

0 commit comments

Comments
 (0)