Fix mpdf writer to work with MPDF 6.1.3 (#76)
Fix old namespace. New writer tested with MPDF 6.1.3
This commit is contained in:
parent
5a8acce94c
commit
66f37218c9
|
@ -30,6 +30,8 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
* Create a mPDF Writer instance.
|
* Create a mPDF Writer instance.
|
||||||
*
|
*
|
||||||
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Spreadsheet object
|
* @param \PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet Spreadsheet object
|
||||||
|
*
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet)
|
public function __construct(\PhpOffice\PhpSpreadsheet\Spreadsheet $spreadsheet)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +52,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
* @param string $pFilename Name of the file to save as
|
* @param string $pFilename Name of the file to save as
|
||||||
*
|
*
|
||||||
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
|
||||||
|
* @throws \PhpOffice\PhpSpreadsheet\Exception
|
||||||
*/
|
*/
|
||||||
public function save($pFilename = null)
|
public function save($pFilename = null)
|
||||||
{
|
{
|
||||||
|
@ -59,7 +62,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
$paperSize = 'LETTER'; // Letter (8.5 in. by 11 in.)
|
||||||
|
|
||||||
// Check for paper size and page orientation
|
// Check for paper size and page orientation
|
||||||
if (is_null($this->getSheetIndex())) {
|
if (null === $this->getSheetIndex()) {
|
||||||
$orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation()
|
$orientation = ($this->spreadsheet->getSheet(0)->getPageSetup()->getOrientation()
|
||||||
== \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
|
== \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_LANDSCAPE) ? 'L' : 'P';
|
||||||
$printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize();
|
$printPaperSize = $this->spreadsheet->getSheet(0)->getPageSetup()->getPaperSize();
|
||||||
|
@ -73,7 +76,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
$this->setOrientation($orientation);
|
$this->setOrientation($orientation);
|
||||||
|
|
||||||
// Override Page Orientation
|
// Override Page Orientation
|
||||||
if (!is_null($this->getOrientation())) {
|
if (null !== $this->getOrientation()) {
|
||||||
$orientation = ($this->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_DEFAULT)
|
$orientation = ($this->getOrientation() == \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_DEFAULT)
|
||||||
? \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT
|
? \PhpOffice\PhpSpreadsheet\Worksheet\PageSetup::ORIENTATION_PORTRAIT
|
||||||
: $this->getOrientation();
|
: $this->getOrientation();
|
||||||
|
@ -81,7 +84,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
$orientation = strtoupper($orientation);
|
$orientation = strtoupper($orientation);
|
||||||
|
|
||||||
// Override Paper Size
|
// Override Paper Size
|
||||||
if (!is_null($this->getPaperSize())) {
|
if (null !== $this->getPaperSize()) {
|
||||||
$printPaperSize = $this->getPaperSize();
|
$printPaperSize = $this->getPaperSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +93,7 @@ class MPDF extends Core implements \PhpOffice\PhpSpreadsheet\Writer\IWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create PDF
|
// Create PDF
|
||||||
$pdf = new \Mpdf\Mpdf();
|
$pdf = new \Mpdf();
|
||||||
$ortmp = $orientation;
|
$ortmp = $orientation;
|
||||||
$pdf->_setPageSize(strtoupper($paperSize), $ortmp);
|
$pdf->_setPageSize(strtoupper($paperSize), $ortmp);
|
||||||
$pdf->DefOrientation = $orientation;
|
$pdf->DefOrientation = $orientation;
|
||||||
|
|
Loading…
Reference in New Issue