Beispiel #1
0
 /**
  * Set page size and orientation
  *
  * @param string Page size (ex. A4, letter, legal)
  * @param string Page orientation (ex. portrait, landscape)
  *
  * @return bool True on success, false if parameters are invalid
  */
 public function setPage($ps_size, $ps_orientation, $ps_margin_top = 0, $ps_margin_right = 0, $ps_margin_bottom = 0, $ps_margin_left = 0)
 {
     if (!PDFRenderer::isValidPageSize($ps_size) || !PDFRenderer::isValidOrientation($ps_orientation)) {
         return false;
     }
     $this->ops_page_size = $ps_size;
     $this->ops_page_orientation = $ps_orientation;
     $this->ops_margin_top = caConvertMeasurement($ps_margin_top, 'mm') . 'mm';
     $this->ops_margin_right = caConvertMeasurement($ps_margin_right, 'mm') . 'mm';
     $this->ops_margin_bottom = caConvertMeasurement($ps_margin_bottom, 'mm') . 'mm';
     $this->ops_margin_left = caConvertMeasurement($ps_margin_left, 'mm') . 'mm';
     return true;
 }
 /** 
  * Get page width and height for a specific page type
  *
  * @param string $ps_size A valid page size (eg. A4, letter, legal)
  * @param string $ps_units Units to return measurements in (eg. mm, cm, in)
  * @param string $ps_orientation Orientation of page (eg. portrait, landscape)
  *
  * @return array Array with width and height keys
  */
 public static function getPageSize($ps_size, $ps_units = 'mm', $ps_orientation = 'portrait')
 {
     $ps_orientation = strtolower($ps_orientation);
     if (!PDFRenderer::isValidOrientation($ps_orientation)) {
         $ps_orientation = 'portrait';
     }
     $va_page_size = CPDF_Adapter::$PAPER_SIZES[$ps_size];
     $vn_page_width = caConvertMeasurement($va_page_size[2] - $va_page_size[0] . 'px', $ps_units);
     $vn_page_height = caConvertMeasurement($va_page_size[3] - $va_page_size[1] . 'px', $ps_units);
     return $ps_orientation == 'portrait' ? array('width' => $vn_page_width, 'height' => $vn_page_height) : array('width' => $vn_page_height, 'height' => $vn_page_width);
 }