allow to use customized pdf library
This commit is contained in:
parent
ec1b3d35ee
commit
c8de86a7ec
|
|
@ -109,6 +109,7 @@ abstract class AbstractContainer extends AbstractElement
|
||||||
} else {
|
} else {
|
||||||
// All other elements
|
// All other elements
|
||||||
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
array_unshift($args, $element); // Prepend element name to the beginning of args array
|
||||||
|
|
||||||
return call_user_func_array(array($this, 'addElement'), $args);
|
return call_user_func_array(array($this, 'addElement'), $args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,16 @@ class DomPDF extends AbstractRenderer implements WriterInterface
|
||||||
*/
|
*/
|
||||||
protected $includeFile = null;
|
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.
|
* Save PhpWord to file.
|
||||||
*
|
*
|
||||||
|
|
@ -49,7 +59,7 @@ class DomPDF extends AbstractRenderer implements WriterInterface
|
||||||
$orientation = 'portrait';
|
$orientation = 'portrait';
|
||||||
|
|
||||||
// Create PDF
|
// Create PDF
|
||||||
$pdf = new DompdfLib();
|
$pdf = $this->createExternalWriterInstance();
|
||||||
$pdf->setPaper(strtolower($paperSize), $orientation);
|
$pdf->setPaper(strtolower($paperSize), $orientation);
|
||||||
$pdf->loadHtml(str_replace(PHP_EOL, '', $this->getContent()));
|
$pdf->loadHtml(str_replace(PHP_EOL, '', $this->getContent()));
|
||||||
$pdf->render();
|
$pdf->render();
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,18 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
||||||
parent::__construct($phpWord);
|
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.
|
* Save PhpWord to file.
|
||||||
*
|
*
|
||||||
|
|
@ -58,8 +70,7 @@ class MPDF extends AbstractRenderer implements WriterInterface
|
||||||
$orientation = strtoupper('portrait');
|
$orientation = strtoupper('portrait');
|
||||||
|
|
||||||
// Create PDF
|
// Create PDF
|
||||||
$mPdfClass = $this->getMPdfClassName();
|
$pdf = $this->createExternalWriterInstance();
|
||||||
$pdf = new $mPdfClass();
|
|
||||||
$pdf->_setPageSize($paperSize, $orientation);
|
$pdf->_setPageSize($paperSize, $orientation);
|
||||||
$pdf->addPage($orientation);
|
$pdf->addPage($orientation);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue