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.
This commit is contained in:
Maxim 2020-07-23 18:49:25 +03:00 committed by GitHub
parent 21f4bb3053
commit d6260988bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -36,6 +36,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
*/ */
protected $includeFile = 'tcpdf.php'; protected $includeFile = 'tcpdf.php';
/**
* Gets the implementation of external PDF library that should be used.
*
* @param string $orientation Page orientation
* @param string $unit Unit measure
* @param string $paperSize Paper size
*
* @return \TCPDF implementation
*/
protected function createExternalWriterInstance($orientation, $unit, $paperSize)
{
return new \TCPDF($orientation, $unit, $paperSize);
}
/** /**
* Save PhpWord to file. * Save PhpWord to file.
* *
@ -50,7 +64,7 @@ class TCPDF extends AbstractRenderer implements WriterInterface
$orientation = 'P'; $orientation = 'P';
// Create PDF // Create PDF
$pdf = new \TCPDF($orientation, 'pt', $paperSize); $pdf = $this->createExternalWriterInstance($orientation, 'pt', $paperSize);
$pdf->setFontSubsetting(false); $pdf->setFontSubsetting(false);
$pdf->setPrintHeader(false); $pdf->setPrintHeader(false);
$pdf->setPrintFooter(false); $pdf->setPrintFooter(false);