Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
13 / 13 |
|
100.00% |
13 / 13 |
CRAP | |
100.00% |
1 / 1 |
| PageSize | |
100.00% |
13 / 13 |
|
100.00% |
13 / 13 |
13 | |
100.00% |
1 / 1 |
| letter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| legal | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| tabloid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a0 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a1 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a2 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a3 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a4 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a5 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| a6 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| b4 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| b5 | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| landscape | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Geometry; |
| 6 | |
| 7 | /** |
| 8 | * Standard page dimensions as Rectangles in PDF points (1/72 inch). |
| 9 | * |
| 10 | * ISO 216 (A0–A6, B4–B5) and North American sizes (Letter, Legal, |
| 11 | * Tabloid). All returned in portrait orientation — use `landscape()` |
| 12 | * to swap width and height. |
| 13 | */ |
| 14 | final class PageSize |
| 15 | { |
| 16 | // All sizes in PDF points (1/72 inch), portrait orientation |
| 17 | public static function letter(): Rectangle |
| 18 | { |
| 19 | return new Rectangle(0, 0, 612, 792); |
| 20 | } |
| 21 | public static function legal(): Rectangle |
| 22 | { |
| 23 | return new Rectangle(0, 0, 612, 1008); |
| 24 | } |
| 25 | public static function tabloid(): Rectangle |
| 26 | { |
| 27 | return new Rectangle(0, 0, 792, 1224); |
| 28 | } |
| 29 | public static function a0(): Rectangle |
| 30 | { |
| 31 | return new Rectangle(0, 0, 2384, 3370); |
| 32 | } |
| 33 | public static function a1(): Rectangle |
| 34 | { |
| 35 | return new Rectangle(0, 0, 1684, 2384); |
| 36 | } |
| 37 | public static function a2(): Rectangle |
| 38 | { |
| 39 | return new Rectangle(0, 0, 1191, 1684); |
| 40 | } |
| 41 | public static function a3(): Rectangle |
| 42 | { |
| 43 | return new Rectangle(0, 0, 842, 1191); |
| 44 | } |
| 45 | public static function a4(): Rectangle |
| 46 | { |
| 47 | return new Rectangle(0, 0, 595, 842); |
| 48 | } |
| 49 | public static function a5(): Rectangle |
| 50 | { |
| 51 | return new Rectangle(0, 0, 420, 595); |
| 52 | } |
| 53 | public static function a6(): Rectangle |
| 54 | { |
| 55 | return new Rectangle(0, 0, 298, 420); |
| 56 | } |
| 57 | public static function b4(): Rectangle |
| 58 | { |
| 59 | return new Rectangle(0, 0, 709, 1001); |
| 60 | } |
| 61 | public static function b5(): Rectangle |
| 62 | { |
| 63 | return new Rectangle(0, 0, 499, 709); |
| 64 | } |
| 65 | public static function landscape(Rectangle $portrait): Rectangle |
| 66 | { |
| 67 | return new Rectangle(0, 0, $portrait->height, $portrait->width); |
| 68 | } |
| 69 | } |