/** * New PDF page * TODO: try and make it possible to do in __construct again * * @param PdfDocument $pdfDocument * @param string $orientation * @param string $size * @throws PdfException */ public function initPage(PdfDocument $pdfDocument, $orientation, $size) { $this->_pdfDocument = $pdfDocument; $this->pageBuffer = "2 J\n"; $size = $this->_getPageSize($size); $this->_curPageSize = $size; $orientation = strtolower($orientation); if ($orientation == 'p' || $orientation == 'portrait') { $this->_curOrientation = 'P'; $this->_w = $size[0]; $this->_h = $size[1]; } elseif ($orientation == 'l' || $orientation == 'landscape') { $this->_curOrientation = 'L'; $this->_w = $size[1]; $this->_h = $size[0]; } else { throw new PdfException('Incorrect orientation: ' . $orientation); } $this->_wPt = $this->_w * $pdfDocument->getScaleFactor(); $this->_hPt = $this->_h * $pdfDocument->getScaleFactor(); if ($pdfDocument->getCurPageNo() > 1) { $defPageSize = $pdfDocument->getDefPageSize(); if ($orientation != $pdfDocument->getDefOrientation() || $size[0] != $defPageSize[0] || $size[1] != $defPageSize[1]) { $pdfDocument->addPageSize($this->_wPt, $this->_hPt); } } else { $pdfDocument->setDefPageSize($this->getCurPageSize()); } $margin = 28.35 / $pdfDocument->getScaleFactor(); $this->setMargins($margin, $margin); $this->_cMargin = $margin / 10; $this->setLineWidth(0.5669999999999999 / $pdfDocument->getScaleFactor()); $this->setAutoPageBreak(true, 2 * $margin); $this->_x = $this->_lMargin; $this->_y = $this->_tMargin; }