array(297, 420, 'mm'), 'A4' => array(210, 297, 'mm'), 'A5' => array(148, 210, 'mm'), 'Folio' => array(8.5, 13, 'in'), 'Legal' => array(8.5, 14, 'in'), 'Letter' => array(8.5, 11, 'in'), ); /** * Paper size * * @var string */ private $size = 'A4'; /** * Width * * @var int (twip) */ private $width; /** * Height * * @var int (twip) */ private $height; /** * Create a new instance * * @param string $size */ public function __construct($size = 'A4') { $this->setSize($size); } /** * Get size * * @return string */ public function getSize() { return $this->size; } /** * Set size * * @param string $size * @return self */ public function setSize($size) { $this->size = $this->setEnumVal($size, array_keys($this->sizes), $this->size); list($width, $height, $unit) = $this->sizes[$this->size]; $multipliers = array('mm' => 56.5217, 'in' => 1440); $multiplier = $multipliers[$unit]; $this->width = (int)round($width * $multiplier); $this->height = (int)round($height * $multiplier); return $this; } /** * Get width * * @return int */ public function getWidth() { return $this->width; } /** * Get height * * @return int */ public function getHeight() { return $this->height; } }