Merge pull request #1983 from FCG-Group/allow_to_use_customized_pdf_libraries
allow to use customized pdf library
This commit is contained in:
commit
7c7d7fd405
|
|
@ -35,6 +35,16 @@ class DomPDF extends AbstractRenderer implements WriterInterface
|
|||
*/
|
||||
protected $includeFile = null;
|
||||
|
||||
/**
|
||||
* Gets the implementation of external PDF library that should be used.
|
||||
*
|
||||
* @return Dompdf implementation
|
||||
*/
|
||||
protected function createExternalWriterInstance()
|
||||
{
|
||||
return new DompdfLib();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PhpWord to file.
|
||||
*
|
||||
|
|
@ -49,7 +59,7 @@ class DomPDF extends AbstractRenderer implements WriterInterface
|
|||
$orientation = 'portrait';
|
||||
|
||||
// Create PDF
|
||||
$pdf = new DompdfLib();
|
||||
$pdf = $this->createExternalWriterInstance();
|
||||
$pdf->setPaper(strtolower($paperSize), $orientation);
|
||||
$pdf->loadHtml(str_replace(PHP_EOL, '', $this->getContent()));
|
||||
$pdf->render();
|
||||
|
|
|
|||
|
|
@ -44,6 +44,18 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
|||
parent::__construct($phpWord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the implementation of external PDF library that should be used.
|
||||
*
|
||||
* @return Mpdf implementation
|
||||
*/
|
||||
protected function createExternalWriterInstance()
|
||||
{
|
||||
$mPdfClass = $this->getMPdfClassName();
|
||||
|
||||
return new $mPdfClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save PhpWord to file.
|
||||
*
|
||||
|
|
@ -58,8 +70,7 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
|||
$orientation = strtoupper('portrait');
|
||||
|
||||
// Create PDF
|
||||
$mPdfClass = $this->getMPdfClassName();
|
||||
$pdf = new $mPdfClass();
|
||||
$pdf = $this->createExternalWriterInstance();
|
||||
$pdf->_setPageSize($paperSize, $orientation);
|
||||
$pdf->addPage($orientation);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,20 @@ class TCPDF extends AbstractRenderer implements WriterInterface
|
|||
return new \TCPDF($orientation, $unit, $paperSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue