/** * Change the format of the current page * @param $format (mixed) The format used for pages. It can be either: one of the string values specified at getPageSizeFromFormat() documentation or an array of two numners (width, height) or an array containing the following measures and options:<ul> * <li>['format'] = page format name (one of the above);</li> * <li>['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.</li> * <li>['PZ'] : The page's preferred zoom (magnification) factor.</li> * <li>['MediaBox'] : the boundaries of the physical medium on which the page shall be displayed or printed:</li> * <li>['MediaBox']['llx'] : lower-left x coordinate in points</li> * <li>['MediaBox']['lly'] : lower-left y coordinate in points</li> * <li>['MediaBox']['urx'] : upper-right x coordinate in points</li> * <li>['MediaBox']['ury'] : upper-right y coordinate in points</li> * <li>['CropBox'] : the visible region of default user space:</li> * <li>['CropBox']['llx'] : lower-left x coordinate in points</li> * <li>['CropBox']['lly'] : lower-left y coordinate in points</li> * <li>['CropBox']['urx'] : upper-right x coordinate in points</li> * <li>['CropBox']['ury'] : upper-right y coordinate in points</li> * <li>['BleedBox'] : the region to which the contents of the page shall be clipped when output in a production environment:</li> * <li>['BleedBox']['llx'] : lower-left x coordinate in points</li> * <li>['BleedBox']['lly'] : lower-left y coordinate in points</li> * <li>['BleedBox']['urx'] : upper-right x coordinate in points</li> * <li>['BleedBox']['ury'] : upper-right y coordinate in points</li> * <li>['TrimBox'] : the intended dimensions of the finished page after trimming:</li> * <li>['TrimBox']['llx'] : lower-left x coordinate in points</li> * <li>['TrimBox']['lly'] : lower-left y coordinate in points</li> * <li>['TrimBox']['urx'] : upper-right x coordinate in points</li> * <li>['TrimBox']['ury'] : upper-right y coordinate in points</li> * <li>['ArtBox'] : the extent of the page's meaningful content:</li> * <li>['ArtBox']['llx'] : lower-left x coordinate in points</li> * <li>['ArtBox']['lly'] : lower-left y coordinate in points</li> * <li>['ArtBox']['urx'] : upper-right x coordinate in points</li> * <li>['ArtBox']['ury'] : upper-right y coordinate in points</li> * <li>['BoxColorInfo'] :specify the colours and other visual characteristics that should be used in displaying guidelines on the screen for each of the possible page boundaries other than the MediaBox:</li> * <li>['BoxColorInfo'][BOXTYPE]['C'] : an array of three numbers in the range 0-255, representing the components in the DeviceRGB colour space.</li> * <li>['BoxColorInfo'][BOXTYPE]['W'] : the guideline width in default user units</li> * <li>['BoxColorInfo'][BOXTYPE]['S'] : the guideline style: S = Solid; D = Dashed</li> * <li>['BoxColorInfo'][BOXTYPE]['D'] : dash array defining a pattern of dashes and gaps to be used in drawing dashed guidelines</li> * <li>['trans'] : the style and duration of the visual transition to use when moving from another page to the given page during a presentation</li> * <li>['trans']['Dur'] : The page's display duration (also called its advance timing): the maximum length of time, in seconds, that the page shall be displayed during presentations before the viewer application shall automatically advance to the next page.</li> * <li>['trans']['S'] : transition style : Split, Blinds, Box, Wipe, Dissolve, Glitter, R, Fly, Push, Cover, Uncover, Fade</li> * <li>['trans']['D'] : The duration of the transition effect, in seconds.</li> * <li>['trans']['Dm'] : (Split and Blinds transition styles only) The dimension in which the specified transition effect shall occur: H = Horizontal, V = Vertical. Default value: H.</li> * <li>['trans']['M'] : (Split, Box and Fly transition styles only) The direction of motion for the specified transition effect: I = Inward from the edges of the page, O = Outward from the center of the pageDefault value: I.</li> * <li>['trans']['Di'] : (Wipe, Glitter, Fly, Cover, Uncover and Push transition styles only) The direction in which the specified transition effect shall moves, expressed in degrees counterclockwise starting from a left-to-right direction. If the value is a number, it shall be one of: 0 = Left to right, 90 = Bottom to top (Wipe only), 180 = Right to left (Wipe only), 270 = Top to bottom, 315 = Top-left to bottom-right (Glitter only). If the value is a name, it shall be None, which is relevant only for the Fly transition when the value of SS is not 1.0. Default value: 0.</li> * <li>['trans']['SS'] : (Fly transition style only) The starting or ending scale at which the changes shall be drawn. If M specifies an inward transition, the scale of the changes drawn shall progress from SS to 1.0 over the course of the transition. If M specifies an outward transition, the scale of the changes drawn shall progress from 1.0 to SS over the course of the transition. Default: 1.0.</li> * <li>['trans']['B'] : (Fly transition style only) If true, the area that shall be flown in is rectangular and opaque. Default: false.</li> * </ul> * @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> * @protected * @since 3.0.015 (2008-06-06) * @see getPageSizeFromFormat() */ protected function setPageFormat($format, $orientation = 'P') { if (!empty($format) and isset($this->pagedim[$this->page])) { // remove inherited values unset($this->pagedim[$this->page]); } if (is_string($format)) { // get page measures from format name $pf = TCPDF_STATIC::getPageSizeFromFormat($format); $this->fwPt = $pf[0]; $this->fhPt = $pf[1]; } else { // the boundaries of the physical medium on which the page shall be displayed or printed if (isset($format['MediaBox'])) { $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'MediaBox', $format['MediaBox']['llx'], $format['MediaBox']['lly'], $format['MediaBox']['urx'], $format['MediaBox']['ury'], false, $this->k, $this->pagedim); $this->fwPt = ($format['MediaBox']['urx'] - $format['MediaBox']['llx']) * $this->k; $this->fhPt = ($format['MediaBox']['ury'] - $format['MediaBox']['lly']) * $this->k; } else { if (isset($format[0]) and is_numeric($format[0]) and isset($format[1]) and is_numeric($format[1])) { $pf = array($format[0] * $this->k, $format[1] * $this->k); } else { if (!isset($format['format'])) { // default value $format['format'] = 'A4'; } $pf = TCPDF_STATIC::getPageSizeFromFormat($format['format']); } $this->fwPt = $pf[0]; $this->fhPt = $pf[1]; $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'MediaBox', 0, 0, $this->fwPt, $this->fhPt, true, $this->k, $this->pagedim); } // the visible region of default user space if (isset($format['CropBox'])) { $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'CropBox', $format['CropBox']['llx'], $format['CropBox']['lly'], $format['CropBox']['urx'], $format['CropBox']['ury'], false, $this->k, $this->pagedim); } // the region to which the contents of the page shall be clipped when output in a production environment if (isset($format['BleedBox'])) { $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'BleedBox', $format['BleedBox']['llx'], $format['BleedBox']['lly'], $format['BleedBox']['urx'], $format['BleedBox']['ury'], false, $this->k, $this->pagedim); } // the intended dimensions of the finished page after trimming if (isset($format['TrimBox'])) { $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'TrimBox', $format['TrimBox']['llx'], $format['TrimBox']['lly'], $format['TrimBox']['urx'], $format['TrimBox']['ury'], false, $this->k, $this->pagedim); } // the page's meaningful content (including potential white space) if (isset($format['ArtBox'])) { $this->pagedim = TCPDF_STATIC::setPageBoxes($this->page, 'ArtBox', $format['ArtBox']['llx'], $format['ArtBox']['lly'], $format['ArtBox']['urx'], $format['ArtBox']['ury'], false, $this->k, $this->pagedim); } // specify the colours and other visual characteristics that should be used in displaying guidelines on the screen for the various page boundaries if (isset($format['BoxColorInfo'])) { $this->pagedim[$this->page]['BoxColorInfo'] = $format['BoxColorInfo']; } if (isset($format['Rotate']) and $format['Rotate'] % 90 == 0) { // 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'] = intval($format['Rotate']); } if (isset($format['PZ'])) { // The page's preferred zoom (magnification) factor $this->pagedim[$this->page]['PZ'] = floatval($format['PZ']); } if (isset($format['trans'])) { // The style and duration of the visual transition to use when moving from another page to the given page during a presentation if (isset($format['trans']['Dur'])) { // The page's display duration $this->pagedim[$this->page]['trans']['Dur'] = floatval($format['trans']['Dur']); } $stansition_styles = array('Split', 'Blinds', 'Box', 'Wipe', 'Dissolve', 'Glitter', 'R', 'Fly', 'Push', 'Cover', 'Uncover', 'Fade'); if (isset($format['trans']['S']) and in_array($format['trans']['S'], $stansition_styles)) { // The transition style that shall be used when moving to this page from another during a presentation $this->pagedim[$this->page]['trans']['S'] = $format['trans']['S']; $valid_effect = array('Split', 'Blinds'); $valid_vals = array('H', 'V'); if (isset($format['trans']['Dm']) and in_array($format['trans']['S'], $valid_effect) and in_array($format['trans']['Dm'], $valid_vals)) { $this->pagedim[$this->page]['trans']['Dm'] = $format['trans']['Dm']; } $valid_effect = array('Split', 'Box', 'Fly'); $valid_vals = array('I', 'O'); if (isset($format['trans']['M']) and in_array($format['trans']['S'], $valid_effect) and in_array($format['trans']['M'], $valid_vals)) { $this->pagedim[$this->page]['trans']['M'] = $format['trans']['M']; } $valid_effect = array('Wipe', 'Glitter', 'Fly', 'Cover', 'Uncover', 'Push'); if (isset($format['trans']['Di']) and in_array($format['trans']['S'], $valid_effect)) { if (($format['trans']['Di'] == 90 or $format['trans']['Di'] == 180) and $format['trans']['S'] == 'Wipe' or $format['trans']['Di'] == 315 and $format['trans']['S'] == 'Glitter' or ($format['trans']['Di'] == 0 or $format['trans']['Di'] == 270)) { $this->pagedim[$this->page]['trans']['Di'] = intval($format['trans']['Di']); } } if (isset($format['trans']['SS']) and $format['trans']['S'] == 'Fly') { $this->pagedim[$this->page]['trans']['SS'] = floatval($format['trans']['SS']); } if (isset($format['trans']['B']) and $format['trans']['B'] === true and $format['trans']['S'] == 'Fly') { $this->pagedim[$this->page]['trans']['B'] = 'true'; } } else { $this->pagedim[$this->page]['trans']['S'] = 'R'; } if (isset($format['trans']['D'])) { // The duration of the transition effect, in seconds $this->pagedim[$this->page]['trans']['D'] = floatval($format['trans']['D']); } else { $this->pagedim[$this->page]['trans']['D'] = 1; } } } $this->setPageOrientation($orientation); }