src/Pdf/Html/Backend.php
public function setPaperSize($size)
	{
		if (isset($size['format']))
		{
			switch (strtolower($size['format']))
			{
				case 'a0':
					$size['width'] = '841mm';
					$size['height'] = '1189mm';
				break;

				case 'a1':
					$size['width'] = '594mm';
					$size['height'] = '841mm';
				break;

				case 'a2':
					$size['width'] = '420mm';
					$size['height'] = '594mm';
				break;

				case 'a3':
					$size['width'] = '297mm';
					$size['height'] = '420mm';
				break;

				case 'a4':
					$size['width'] = '210mm';
					$size['height'] = '297mm';
				break;

				case 'a5':
					$size['width'] = '148mm';
					$size['height'] = '210mm';
				break;

				case 'a6':
					$size['width'] = '105mm';
					$size['height'] = '148mm';
				break;

				case 'a7':
					$size['width'] = '74mm';
					$size['height'] = '105mm';
				break;

				case 'a8':
					$size['width'] = '52mm';
					$size['height'] = '74mm';
				break;

				case 'a9':
					$size['width'] = '37mm';
					$size['height'] = '52mm';
				break;

				case 'a10':
					$size['width'] = '27mm';
					$size['height'] = '37mm';
				break;

				case 'letter':
					$size['width'] = '216mm';
					$size['height'] = '280mm';
				break;

				case 'legal':
					$size['width'] = '215.9mm';
					$size['height'] = '255.6mm';
				break;

				default:
					throw new RuntimeException('Unregcognised Paper Size!');
				break;
			}

			// Swap the dimensions around if landscape
			if (isset($size['orientation']))
			{
				if ($size['orientation'] == 'landscape')
				{
					$width = $size['width'];
					$height = $size['height'];
					$size['width'] = $height;
					$size['height'] = $width;
				}
			}
		}

		$this->paperSize = $size;

		return $this;
	}
public function setPaperSize($size)
	{
		if (isset($size['format']))
		{
			switch (strtolower($size['format']))
			{
				case 'a0':
					$size['width'] = '841mm';
					$size['height'] = '1189mm';
				break;

				case 'a1':
					$size['width'] = '594mm';
					$size['height'] = '841mm';
				break;

				case 'a2':
					$size['width'] = '420mm';
					$size['height'] = '594mm';
				break;

				case 'a3':
					$size['width'] = '297mm';
					$size['height'] = '420mm';
				break;

				case 'a4':
					$size['width'] = '210mm';
					$size['height'] = '297mm';
				break;

				case 'a5':
					$size['width'] = '148mm';
					$size['height'] = '210mm';
				break;

				case 'a6':
					$size['width'] = '105mm';
					$size['height'] = '148mm';
				break;

				case 'a7':
					$size['width'] = '74mm';
					$size['height'] = '105mm';
				break;

				case 'a8':
					$size['width'] = '52mm';
					$size['height'] = '74mm';
				break;

				case 'a9':
					$size['width'] = '37mm';
					$size['height'] = '52mm';
				break;

				case 'a10':
					$size['width'] = '27mm';
					$size['height'] = '37mm';
				break;

				case 'letter':
					$size['width'] = '216mm';
					$size['height'] = '280mm';
				break;

				case 'legal':
					$size['width'] = '215.9mm';
					$size['height'] = '255.6mm';
				break;

				default:
					throw new RuntimeException('Unregcognised Paper Size!');
				break;
			}

			// Swap the dimensions around if landscape
			if (isset($size['orientation']))
			{
				if ($size['orientation'] == 'landscape')
				{
					$width = $size['width'];
					$height = $size['height'];
					$size['width'] = $height;
					$size['height'] = $width;
				}
			}
		}

		$this->paperSize = $size;

		return $this;
	}
public function setPaperSize ( $ size ) { if ( isset ( $ size [ 'format' ] ) ) { switch ( strtolower ( $ size [ 'format' ] ) ) { case 'a0' : $ size [ 'width' ] = '841mm' ; $ size [ 'height' ] = '1189mm' ; break ; case 'a1' : $ size [ 'width' ] = '594mm' ; $ size [ 'height' ] = '841mm' ; break ; case 'a2' : $ size [ 'width' ] = '420mm' ; $ size [ 'height' ] = '594mm' ; break ; case 'a3' : $ size [ 'width' ] = '297mm' ; $ size [ 'height' ] = '420mm' ; break ; case 'a4' : $ size [ 'width' ] = '210mm' ; $ size [ 'height' ] = '297mm' ; break ; case 'a5' : $ size [ 'width' ] = '148mm' ; $ size [ 'height' ] = '210mm' ; break ; case 'a6' : $ size [ 'width' ] = '105mm' ; $ size [ 'height' ] = '148mm' ; break ; case 'a7' : $ size [ 'width' ] = '74mm' ; $ size [ 'height' ] = '105mm' ; break ; case 'a8' : $ size [ 'width' ] = '52mm' ; $ size [ 'height' ] = '74mm' ; break ; case 'a9' : $ size [ 'width' ] = '37mm' ; $ size [ 'height' ] = '52mm' ; break ; case 'a10' : $ size [ 'width' ] = '27mm' ; $ size [ 'height' ] = '37mm' ; break ; case 'letter' : $ size [ 'width' ] = '216mm' ; $ size [ 'height' ] = '280mm' ; break ; case 'legal' : $ size [ 'width' ] = '215.9mm' ; $ size [ 'height' ] = '255.6mm' ; break ; default : throw new RuntimeException ( 'Unregcognised Paper Size!' ) ; break ; } // Swap the dimensions around if landscape if ( isset ( $ size [ 'orientation' ] ) ) { if ( $ size [ 'orientation' ] == 'landscape' ) { $ width = $ size [ 'width' ] ; $ height = $ size [ 'height' ] ; $ size [ 'width' ] = $ height ; $ size [ 'height' ] = $ width ; } } } $ this -> paperSize = $ size ; return $ this ; }
Paper Size Setter

It is easier to work with numbers, so while I understand phantomjs does
have it's own paper size format and orientation settings. Here we provide
a basic lookup table to convert A4, A3, Letter, etc...
Into their metric counterparts.

@param array $size

@return self
Paper Size Setter