1<?php 2 3namespace Mpdf; 4 5class PageFormat 6{ 7 8 /** 9 * This method returns an array of width and height of given named format. 10 * 11 * Returned values are milimeters multiplied by scale factor of 72 / 25.4 12 * 13 * @param string $name 14 * @return float[] Width and height of given format 15 */ 16 public static function getSizeFromName($name) 17 { 18 $format = strtoupper($name); 19 $formats = [ 20 '4A0' => [4767.87, 6740.79], 21 '2A0' => [3370.39, 4767.87], 22 'A0' => [2383.94, 3370.39], 23 'A1' => [1683.78, 2383.94], 24 'A2' => [1190.55, 1683.78], 25 'A3' => [841.89, 1190.55], 26 'A4' => [595.28, 841.89], 27 'A5' => [419.53, 595.28], 28 'A6' => [297.64, 419.53], 29 'A7' => [209.76, 297.64], 30 'A8' => [147.40, 209.76], 31 'A9' => [104.88, 147.40], 32 'A10' => [73.70, 104.88], 33 'B0' => [2834.65, 4008.19], 34 'B1' => [2004.09, 2834.65], 35 'B2' => [1417.32, 2004.09], 36 'B3' => [1000.63, 1417.32], 37 'B4' => [708.66, 1000.63], 38 'B5' => [498.90, 708.66], 39 'B6' => [354.33, 498.90], 40 'B7' => [249.45, 354.33], 41 'B8' => [175.75, 249.45], 42 'B9' => [124.72, 175.75], 43 'B10' => [87.87, 124.72], 44 'C0' => [2599.37, 3676.54], 45 'C1' => [1836.85, 2599.37], 46 'C2' => [1298.27, 1836.85], 47 'C3' => [918.43, 1298.27], 48 'C4' => [649.13, 918.43], 49 'C5' => [459.21, 649.13], 50 'C6' => [323.15, 459.21], 51 'C7' => [229.61, 323.15], 52 'C8' => [161.57, 229.61], 53 'C9' => [113.39, 161.57], 54 'C10' => [79.37, 113.39], 55 'RA0' => [2437.80, 3458.27], 56 'RA1' => [1729.13, 2437.80], 57 'RA2' => [1218.90, 1729.13], 58 'RA3' => [864.57, 1218.90], 59 'RA4' => [609.45, 864.57], 60 'SRA0' => [2551.18, 3628.35], 61 'SRA1' => [1814.17, 2551.18], 62 'SRA2' => [1275.59, 1814.17], 63 'SRA3' => [907.09, 1275.59], 64 'SRA4' => [637.80, 907.09], 65 'LETTER' => [612.00, 792.00], 66 'LEGAL' => [612.00, 1008.00], 67 'LEDGER' => [1224.00, 792.00], 68 'TABLOID' => [792.00, 1224.00], 69 'EXECUTIVE' => [521.86, 756.00], 70 'FOLIO' => [612.00, 936.00], 71 'B' => [362.83, 561.26], // 'B' format paperback size 128x198mm 72 'A' => [314.65, 504.57], // 'A' format paperback size 111x178mm 73 'DEMY' => [382.68, 612.28], // 'Demy' format paperback size 135x216mm 74 'ROYAL' => [433.70, 663.30], // 'Royal' format paperback size 153x234mm 75 ]; 76 77 if (!isset($formats[$format])) { 78 throw new \Mpdf\MpdfException(sprintf('Unknown page format %s', $format)); 79 } 80 81 return $formats[$format]; 82 } 83} 84