/** * Set page orientation. * @param $orientation (string) page orientation. Possible values are (case insensitive):<ul><li>P or Portrait (default)</li><li>L or Landscape</li><li>'' (empty string) for automatic orientation</li></ul> * @param $autopagebreak (boolean) Boolean indicating if auto-page-break mode should be on or off. * @param $bottommargin (float) bottom margin of the page. * @public * @since 3.0.015 (2008-06-06) */ public function setPageOrientation($orientation, $autopagebreak = '', $bottommargin = '') { if (!isset($this->pagedim[$this->page]['MediaBox'])) { // the boundaries of the physical medium on which the page shall be displayed or printed $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'MediaBox', 0, 0, $this->fwPt, $this->fhPt, true, $this->k, $this->pagedim); } if (!isset($this->pagedim[$this->page]['CropBox'])) { // the visible region of default user space $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'CropBox', $this->pagedim[$this->page]['MediaBox']['llx'], $this->pagedim[$this->page]['MediaBox']['lly'], $this->pagedim[$this->page]['MediaBox']['urx'], $this->pagedim[$this->page]['MediaBox']['ury'], true, $this->k, $this->pagedim); } if (!isset($this->pagedim[$this->page]['BleedBox'])) { // the region to which the contents of the page shall be clipped when output in a production environment $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'BleedBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true, $this->k, $this->pagedim); } if (!isset($this->pagedim[$this->page]['TrimBox'])) { // the intended dimensions of the finished page after trimming $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'TrimBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true, $this->k, $this->pagedim); } if (!isset($this->pagedim[$this->page]['ArtBox'])) { // the page's meaningful content (including potential white space) $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'ArtBox', $this->pagedim[$this->page]['CropBox']['llx'], $this->pagedim[$this->page]['CropBox']['lly'], $this->pagedim[$this->page]['CropBox']['urx'], $this->pagedim[$this->page]['CropBox']['ury'], true, $this->k, $this->pagedim); } if (!isset($this->pagedim[$this->page]['Rotate'])) { // The number of degrees by which the page shall be rotated clockwise when displayed or printed. The value shall be a multiple of 90. $this->pagedim[$this->page]['Rotate'] = 0; } if (!isset($this->pagedim[$this->page]['PZ'])) { // The page's preferred zoom (magnification) factor $this->pagedim[$this->page]['PZ'] = 1; } if ($this->fwPt > $this->fhPt) { // landscape $default_orientation = 'L'; } else { // portrait $default_orientation = 'P'; } $valid_orientations = array('P', 'L'); if (empty($orientation)) { $orientation = $default_orientation; } else { $orientation = strtoupper($orientation[0]); } if (in_array($orientation, $valid_orientations) and $orientation != $default_orientation) { $this->CurOrientation = $orientation; $this->wPt = $this->fhPt; $this->hPt = $this->fwPt; } else { $this->CurOrientation = $default_orientation; $this->wPt = $this->fwPt; $this->hPt = $this->fhPt; } if (abs($this->pagedim[$this->page]['MediaBox']['urx'] - $this->hPt) < $this->feps and abs($this->pagedim[$this->page]['MediaBox']['ury'] - $this->wPt) < $this->feps) { // swap X and Y coordinates (change page orientation) $this->pagedim = TCPDF_STATIC::swapPageBoxCoordinates($this->page, $this->pagedim); } $this->w = $this->wPt / $this->k; $this->h = $this->hPt / $this->k; if (TCPDF_STATIC::empty_string($autopagebreak)) { if (isset($this->AutoPageBreak)) { $autopagebreak = $this->AutoPageBreak; } else { $autopagebreak = true; } } if (TCPDF_STATIC::empty_string($bottommargin)) { if (isset($this->bMargin)) { $bottommargin = $this->bMargin; } else { // default value = 2 cm $bottommargin = 2 * 28.35 / $this->k; } } $this->SetAutoPageBreak($autopagebreak, $bottommargin); // store page dimensions $this->pagedim[$this->page]['w'] = $this->wPt; $this->pagedim[$this->page]['h'] = $this->hPt; $this->pagedim[$this->page]['wk'] = $this->w; $this->pagedim[$this->page]['hk'] = $this->h; $this->pagedim[$this->page]['tm'] = $this->tMargin; $this->pagedim[$this->page]['bm'] = $bottommargin; $this->pagedim[$this->page]['lm'] = $this->lMargin; $this->pagedim[$this->page]['rm'] = $this->rMargin; $this->pagedim[$this->page]['pb'] = $autopagebreak; $this->pagedim[$this->page]['or'] = $this->CurOrientation; $this->pagedim[$this->page]['olm'] = $this->original_lMargin; $this->pagedim[$this->page]['orm'] = $this->original_rMargin; }