From cafce896994f5c5e26c50e0d7b825c4404be91ca Mon Sep 17 00:00:00 2001 From: Nicola Asuni Date: Fri, 10 Nov 2023 12:21:21 +0000 Subject: [PATCH] Php8 (#3) * Require PHP 8.0+ * Set phpstan max level and fix errors --- .github/workflows/check.yml | 8 +- .gitignore | 4 + README.md | 6 +- VERSION | 2 +- composer.json | 10 +- phpstan.neon | 2 +- resources/debian/control | 2 +- resources/rpm/rpm.spec | 6 +- src/Box.php | 220 ++++++--- src/Exception.php | 28 +- src/Format.php | 890 ++++++++++++++++++------------------ src/Mode.php | 84 ++-- src/Page.php | 606 ++++++++++++++++++++---- src/Region.php | 704 ++++++++++++++++++++++++---- src/Settings.php | 482 ++++++++++++------- test/BoxTest.php | 143 +++--- test/FormatTest.php | 106 +++-- test/ModeTest.php | 58 ++- test/PageTest.php | 320 +++++++------ test/RegionTest.php | 130 +++--- test/SettingsTest.php | 767 +++++++++++++++++++------------ test/TestUtil.php | 64 ++- test/UnitTest.php | 54 ++- 23 files changed, 3024 insertions(+), 1672 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index aa68ef4..defda12 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -23,16 +23,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ["7.2", "7.3", "7.4", "8.0", "8.1", "8.2"] + php-version: ["8.0", "8.1", "8.2"] experimental: [false] os: [ubuntu-latest] coverage-extension: [pcov] - include: - #- { php-version: '5.3', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - #- { php-version: '5.4', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '5.5', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '5.6', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } - - { php-version: '7.1', experimental: false, os: ubuntu-latest, coverage-extension: 'xdebug' } steps: - uses: actions/checkout@v4 - name: Use php ${{ matrix.php-version }} diff --git a/.gitignore b/.gitignore index 291bb86..4dd7d5e 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,14 @@ **/.vagrant **/auth.json **/nbproject +**/temp.php +**/test.php .phpdoc .phpunit.cache .phpunit.result.cache composer.lock +ecs.php phpunit.xml +rector.php target vendor diff --git a/README.md b/README.md index b9408ad..fcab1de 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ All artifacts are generated in the target directory. Examples are located in the `example` directory. -Start a development server (requires PHP 5.4) using the command: +Start a development server (requires PHP 8.0+) using the command: ``` make server @@ -78,7 +78,7 @@ Create a composer.json in your projects root-directory: ```json { "require": { - "tecnickcom/tc-lib-pdf-page": "^2.4" + "tecnickcom/tc-lib-pdf-page": "^4.0" } } ``` @@ -86,7 +86,7 @@ Create a composer.json in your projects root-directory: Or add to an existing project with: ```bash -composer require tecnickcom/tc-lib-pdf-page ^2.4 +composer require tecnickcom/tc-lib-pdf-page ^4.0 ``` diff --git a/VERSION b/VERSION index 17ce918..c4e41f9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.2.11 +4.0.3 diff --git a/composer.json b/composer.json index 51dea39..e04c493 100644 --- a/composer.json +++ b/composer.json @@ -18,17 +18,17 @@ } ], "require": { - "php": ">=5.4", + "php": ">=8.0", "ext-date": "*", "ext-zlib": "*", - "tecnickcom/tc-lib-color": "^1.14", - "tecnickcom/tc-lib-pdf-encrypt": "^1.6" + "tecnickcom/tc-lib-color": "^2.0", + "tecnickcom/tc-lib-pdf-encrypt": "^2.0" }, "require-dev": { "pdepend/pdepend": "2.13.0", "phpmd/phpmd": "2.13.0", - "phpunit/phpunit": "10.1.2 || 9.6.7 || 8.5.31 || 7.5.20 || 6.5.14 || 5.7.27 || 4.8.36", - "squizlabs/php_codesniffer": "3.7.2 || 2.9.2" + "phpunit/phpunit": "10.1.2 || 9.6.13", + "squizlabs/php_codesniffer": "3.7.2" }, "autoload": { "psr-4": { diff --git a/phpstan.neon b/phpstan.neon index c42b364..bf592ce 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,5 +1,5 @@ parameters: - level: 5 + level: max paths: - src - test diff --git a/resources/debian/control b/resources/debian/control index 57d28c1..afe00de 100644 --- a/resources/debian/control +++ b/resources/debian/control @@ -10,6 +10,6 @@ Vcs-Git: https://github.com/~#VENDOR#~/~#PROJECT#~.git Package: ~#PKGNAME#~ Provides: php-~#PROJECT#~ Architecture: all -Depends: php (>= 5.4.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 1.14.39), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 1.6.35), ${misc:Depends} +Depends: php (>= 8.0.0), php-date, php-zip, php-tecnickcom-tc-lib-color (<< 2.0.0), php-tecnickcom-tc-lib-color (>= 2.0.3), php-tecnickcom-tc-lib-pdf-encrypt (<< 2.0.0), php-tecnickcom-tc-lib-pdf-encrypt (>= 2.0.6), ${misc:Depends} Description: PHP PDF Page Library PHP library containing PDF page formats and definitions. diff --git a/resources/rpm/rpm.spec b/resources/rpm/rpm.spec index 4f2b966..a06561a 100644 --- a/resources/rpm/rpm.spec +++ b/resources/rpm/rpm.spec @@ -16,13 +16,13 @@ URL: https://github.com/%{gh_owner}/%{gh_project} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n) BuildArch: noarch -Requires: php(language) >= 5.4.0 +Requires: php(language) >= 8.0.0 Requires: php-date Requires: php-zlib Requires: php-composer(%{c_vendor}/tc-lib-color) < 2.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-color) >= 1.14.39 +Requires: php-composer(%{c_vendor}/tc-lib-color) >= 2.0.3 Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) < 2.0.0 -Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 1.6.35 +Requires: php-composer(%{c_vendor}/tc-lib-pdf-encrypt) >= 2.0.6 Provides: php-composer(%{c_vendor}/%{gh_project}) = %{version} Provides: php-%{gh_project} = %{version} diff --git a/src/Box.php b/src/Box.php index ccd8b7f..3f2d0aa 100644 --- a/src/Box.php +++ b/src/Box.php @@ -3,13 +3,13 @@ /** * Box.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ @@ -22,54 +22,71 @@ /** * Com\Tecnick\Pdf\Page\Box * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ abstract class Box extends \Com\Tecnick\Pdf\Page\Mode { /** * Unit of measure conversion ratio. - * - * @var float */ - protected $kunit = 1.0; + protected float $kunit = 1.0; /** * Color object. - * - * @var Color */ - protected $col; + protected Color $col; /** - * Array of page box names. + * Page box names. * - * @var array + * @var array */ - public static $box = array( + public const BOX = [ 'MediaBox', 'CropBox', 'BleedBox', 'TrimBox', - 'ArtBox' - ); + 'ArtBox', + ]; /** * Swap X and Y coordinates of page boxes (change page boxes orientation). * - * @param array $dims Array of page dimensions. - * - * @return array Page dimensions. + * @param array, + * }, + * }> $dims Array of page dimensions. * + * @return array, + * }, + * }> Page dimensions. */ - public function swapCoordinates(array $dims) + public function swapCoordinates(array $dims): array { - foreach (self::$box as $type) { + foreach (self::BOX as $type) { // swap X and Y coordinates if (isset($dims[$type])) { $tmp = $dims[$type]['llx']; @@ -80,45 +97,83 @@ public function swapCoordinates(array $dims) $dims[$type]['ury'] = $tmp; } } + return $dims; } /** * Set page boundaries. * - * @param array $dims Array of page dimensions to modify. - * @param string $type Box type: MediaBox, CropBox, BleedBox, TrimBox, ArtBox. - * @param float $llx Lower-left x coordinate in user units. - * @param float $lly Lower-left y coordinate in user units. - * @param float $urx Upper-right x coordinate in user units. - * @param float $ury Upper-right y coordinate in user units. - * @param array $bci BoxColorInfo: guideline style (color, width, style, dash). + * @param array, + * }, + * }> $dims Array of page dimensions to modify. + * @param string $type Box type: MediaBox, CropBox, BleedBox, TrimBox, ArtBox. + * @param float $llx Lower-left x coordinate in user units. + * @param float $lly Lower-left y coordinate in user units. + * @param float $urx Upper-right x coordinate in user units. + * @param float $ury Upper-right y coordinate in user units. + * @param array{ + * 'color': string, + * 'width': float, + * 'style': string, + * 'dash': array, + * } $bci BoxColorInfo: guideline style (color, width, style, dash). * - * @return array Page dimensions. + * @return array, + * }, + * }> Page dimensions. */ - public function setBox($dims, $type, $llx, $lly, $urx, $ury, array $bci = array()) - { - if (empty($dims)) { + public function setBox( + array $dims, + string $type, + float $llx, + float $lly, + float $urx, + float $ury, + ?array $bci = null, + ): array { + if ($dims === []) { // initialize array - $dims = array(); + $dims = []; } - if (!in_array($type, self::$box)) { + + if (! in_array($type, self::BOX)) { throw new PageException('unknown page box type: ' . $type); } + $dims[$type]['llx'] = $llx; $dims[$type]['lly'] = $lly; $dims[$type]['urx'] = $urx; $dims[$type]['ury'] = $ury; - if (empty($bci)) { + if ($bci === null) { // set default values - $bci = array( + $bci = [ 'color' => '#000000', 'width' => (1.0 / $this->kunit), 'style' => 'S', // S = solid; D = dash - 'dash' => array(3) - ); + 'dash' => [3], + ]; } + $dims[$type]['bci'] = $bci; return $dims; @@ -130,33 +185,49 @@ public function setBox($dims, $type, $llx, $lly, $urx, $ury, array $bci = array( * @param float $width Page width in points. * @param float $height Page height in points. * - * @return array Page boxes. + * @return array, + * }, + * }> Page boxes. */ - public function setPageBoxes($width, $height) + public function setPageBoxes(float $width, float $height): array { - $dims = array(); - foreach (self::$box as $type) { + $dims = []; + foreach (self::BOX as $type) { $dims = $this->setBox($dims, $type, 0, 0, $width, $height); } + return $dims; } /** * Returns the PDF command to output the specified page boxes. * - * @param array $dims Array of page dimensions. - * - * @return string + * @param array $dims Array of page dimensions. */ - protected function getBox(array $dims) + protected function getBox(array $dims): string { $out = ''; - foreach (self::$box as $box) { + foreach (self::BOX as $box) { if (empty($dims[$box])) { // @codeCoverageIgnoreStart continue; // @codeCoverageIgnoreEnd } + $out .= '/' . $box . ' [' . sprintf( '%F %F %F %F', $dims[$box]['llx'], @@ -165,49 +236,62 @@ protected function getBox(array $dims) $dims[$box]['ury'] ) . ']' . "\n"; } + return $out; } /** * Returns the PDF command to output the specified page BoxColorInfo. * - * @param array $dims Array of page dimensions. + * @param array, + * }, + * }> $dims Array of page dimensions. * - * @return string + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ - protected function getBoxColorInfo(array $dims) + protected function getBoxColorInfo(array $dims): string { $out = '/BoxColorInfo <<' . "\n"; - foreach (self::$box as $box) { + foreach (self::BOX as $box) { if (empty($dims[$box])) { - // @codeCoverageIgnoreStart continue; - // @codeCoverageIgnoreEnd } + $out .= '/' . $box . ' <<' . "\n"; - if (!empty($dims[$box]['bci']['color'])) { + if (! empty($dims[$box]['bci']['color'])) { $out .= '/C [' . $this->col->getPdfRgbComponents($dims[$box]['bci']['color']) . ']' . "\n"; } - if (!empty($dims[$box]['bci']['width'])) { + + if (! empty($dims[$box]['bci']['width'])) { $out .= '/W ' . sprintf('%F', ($dims[$box]['bci']['width'] * $this->kunit)) . "\n"; } - if (!empty($dims[$box]['bci']['style'])) { + + if (! empty($dims[$box]['bci']['style'])) { $mode = strtoupper($dims[$box]['bci']['style'][0]); if ($mode !== 'D') { $mode = 'S'; } + $out .= '/S /' . $mode . "\n"; } - if (!empty($dims[$box]['bci']['dash'])) { + + if (! empty($dims[$box]['bci']['dash'])) { $out .= '/D ['; foreach ($dims[$box]['bci']['dash'] as $dash) { $out .= sprintf(' %F', ((float) $dash * $this->kunit)); } + $out .= ' ]' . "\n"; } + $out .= '>>' . "\n"; } - $out .= '>>' . "\n"; - return $out; + + return $out . ('>>' . "\n"); } } diff --git a/src/Exception.php b/src/Exception.php index 4131c35..c50cff1 100644 --- a/src/Exception.php +++ b/src/Exception.php @@ -3,13 +3,13 @@ /** * Exception.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ @@ -21,13 +21,13 @@ * * Custom Exception class. * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class Exception extends \Exception { diff --git a/src/Format.php b/src/Format.php index f8dba34..54c19a5 100644 --- a/src/Format.php +++ b/src/Format.php @@ -3,13 +3,13 @@ /** * Format.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ @@ -21,13 +21,13 @@ /** * Com\Tecnick\Pdf\Page\Format * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ abstract class Format { @@ -35,445 +35,445 @@ abstract class Format * Array of conversion ratios relative to points. * 72 is the default DPI (Dot Per Inch) document resolution. * - * @var array + * @var array */ - public static $unitratio = array( - '' => 1, // default to points - 'px' => 1, - 'pt' => 1, - 'points' => 1, + public const UNITRATIO = [ + '' => 1.0, // default to points + 'px' => 1.0, + 'pt' => 1.0, + 'points' => 1.0, 'millimeters' => 2.83464566929134, // (72 / 25.4) - 'mm' => 2.83464566929134, // (72 / 25.4) + 'mm' => 2.83464566929134, // (72 / 25.4) 'centimeters' => 28.3464566929134, // (72 / 2.54) - 'cm' => 28.3464566929134, // (72 / 2.54) - 'inches' => 72, - 'in' => 72 - ); + 'cm' => 28.3464566929134, // (72 / 2.54) + 'inches' => 72.0, + 'in' => 72.0, + ]; /** * Array of page formats (width, height). * Measures are calculated in this way: (inches * 72) or (millimeters * 72 / 25.4) * - * @var array + * @var array */ - public static $format = array( + public const FORMAT = [ // ISO 216 A Series + 2 SIS 014711 extensions - 'A0' => array( 2383.937, 3370.394), // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in - 'A1' => array( 1683.780, 2383.937), // = ( 594 x 841 ) mm = ( 23.39 x 33.11 ) in - 'A2' => array( 1190.551, 1683.780), // = ( 420 x 594 ) mm = ( 16.54 x 23.39 ) in - 'A3' => array( 841.890, 1190.551), // = ( 297 x 420 ) mm = ( 11.69 x 16.54 ) in - 'A4' => array( 595.276, 841.890), // = ( 210 x 297 ) mm = ( 8.27 x 11.69 ) in - 'A5' => array( 419.528, 595.276), // = ( 148 x 210 ) mm = ( 5.83 x 8.27 ) in - 'A6' => array( 297.638, 419.528), // = ( 105 x 148 ) mm = ( 4.13 x 5.83 ) in - 'A7' => array( 209.764, 297.638), // = ( 74 x 105 ) mm = ( 2.91 x 4.13 ) in - 'A8' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in - 'A9' => array( 104.882, 147.402), // = ( 37 x 52 ) mm = ( 1.46 x 2.05 ) in - 'A10' => array( 73.701, 104.882), // = ( 26 x 37 ) mm = ( 1.02 x 1.46 ) in - 'A11' => array( 51.024, 73.701), // = ( 18 x 26 ) mm = ( 0.71 x 1.02 ) in - 'A12' => array( 36.850, 51.024), // = ( 13 x 18 ) mm = ( 0.51 x 0.71 ) in + 'A0' => [2383.937, 3370.394], // = ( 841 x 1189 ) mm = ( 33.11 x 46.81 ) in + 'A1' => [1683.780, 2383.937], // = ( 594 x 841 ) mm = ( 23.39 x 33.11 ) in + 'A2' => [1190.551, 1683.780], // = ( 420 x 594 ) mm = ( 16.54 x 23.39 ) in + 'A3' => [841.890, 1190.551], // = ( 297 x 420 ) mm = ( 11.69 x 16.54 ) in + 'A4' => [595.276, 841.890], // = ( 210 x 297 ) mm = ( 8.27 x 11.69 ) in + 'A5' => [419.528, 595.276], // = ( 148 x 210 ) mm = ( 5.83 x 8.27 ) in + 'A6' => [297.638, 419.528], // = ( 105 x 148 ) mm = ( 4.13 x 5.83 ) in + 'A7' => [209.764, 297.638], // = ( 74 x 105 ) mm = ( 2.91 x 4.13 ) in + 'A8' => [147.402, 209.764], // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in + 'A9' => [104.882, 147.402], // = ( 37 x 52 ) mm = ( 1.46 x 2.05 ) in + 'A10' => [73.701, 104.882], // = ( 26 x 37 ) mm = ( 1.02 x 1.46 ) in + 'A11' => [51.024, 73.701], // = ( 18 x 26 ) mm = ( 0.71 x 1.02 ) in + 'A12' => [36.850, 51.024], // = ( 13 x 18 ) mm = ( 0.51 x 0.71 ) in // ISO 216 B Series + 2 SIS 014711 extensions - 'B0' => array( 2834.646, 4008.189), // = ( 1000 x 1414 ) mm = ( 39.37 x 55.67 ) in - 'B1' => array( 2004.094, 2834.646), // = ( 707 x 1000 ) mm = ( 27.83 x 39.37 ) in - 'B2' => array( 1417.323, 2004.094), // = ( 500 x 707 ) mm = ( 19.69 x 27.83 ) in - 'B3' => array( 1000.630, 1417.323), // = ( 353 x 500 ) mm = ( 13.90 x 19.69 ) in - 'B4' => array( 708.661, 1000.630), // = ( 250 x 353 ) mm = ( 9.84 x 13.90 ) in - 'B5' => array( 498.898, 708.661), // = ( 176 x 250 ) mm = ( 6.93 x 9.84 ) in - 'B6' => array( 354.331, 498.898), // = ( 125 x 176 ) mm = ( 4.92 x 6.93 ) in - 'B7' => array( 249.449, 354.331), // = ( 88 x 125 ) mm = ( 3.46 x 4.92 ) in - 'B8' => array( 175.748, 249.449), // = ( 62 x 88 ) mm = ( 2.44 x 3.46 ) in - 'B9' => array( 124.724, 175.748), // = ( 44 x 62 ) mm = ( 1.73 x 2.44 ) in - 'B10' => array( 87.874, 124.724), // = ( 31 x 44 ) mm = ( 1.22 x 1.73 ) in - 'B11' => array( 62.362, 87.874), // = ( 22 x 31 ) mm = ( 0.87 x 1.22 ) in - 'B12' => array( 42.520, 62.362), // = ( 15 x 22 ) mm = ( 0.59 x 0.87 ) in + 'B0' => [2834.646, 4008.189], // = ( 1000 x 1414 ) mm = ( 39.37 x 55.67 ) in + 'B1' => [2004.094, 2834.646], // = ( 707 x 1000 ) mm = ( 27.83 x 39.37 ) in + 'B2' => [1417.323, 2004.094], // = ( 500 x 707 ) mm = ( 19.69 x 27.83 ) in + 'B3' => [1000.630, 1417.323], // = ( 353 x 500 ) mm = ( 13.90 x 19.69 ) in + 'B4' => [708.661, 1000.630], // = ( 250 x 353 ) mm = ( 9.84 x 13.90 ) in + 'B5' => [498.898, 708.661], // = ( 176 x 250 ) mm = ( 6.93 x 9.84 ) in + 'B6' => [354.331, 498.898], // = ( 125 x 176 ) mm = ( 4.92 x 6.93 ) in + 'B7' => [249.449, 354.331], // = ( 88 x 125 ) mm = ( 3.46 x 4.92 ) in + 'B8' => [175.748, 249.449], // = ( 62 x 88 ) mm = ( 2.44 x 3.46 ) in + 'B9' => [124.724, 175.748], // = ( 44 x 62 ) mm = ( 1.73 x 2.44 ) in + 'B10' => [87.874, 124.724], // = ( 31 x 44 ) mm = ( 1.22 x 1.73 ) in + 'B11' => [62.362, 87.874], // = ( 22 x 31 ) mm = ( 0.87 x 1.22 ) in + 'B12' => [42.520, 62.362], // = ( 15 x 22 ) mm = ( 0.59 x 0.87 ) in // ISO 216 C Series + 2 SIS 014711 extensions + 5 EXTENSION - 'C0' => array( 2599.370, 3676.535), // = ( 917 x 1297 ) mm = ( 36.10 x 51.06 ) in - 'C1' => array( 1836.850, 2599.370), // = ( 648 x 917 ) mm = ( 25.51 x 36.10 ) in - 'C2' => array( 1298.268, 1836.850), // = ( 458 x 648 ) mm = ( 18.03 x 25.51 ) in - 'C3' => array( 918.425, 1298.268), // = ( 324 x 458 ) mm = ( 12.76 x 18.03 ) in - 'C4' => array( 649.134, 918.425), // = ( 229 x 324 ) mm = ( 9.02 x 12.76 ) in - 'C5' => array( 459.213, 649.134), // = ( 162 x 229 ) mm = ( 6.38 x 9.02 ) in - 'C6' => array( 323.150, 459.213), // = ( 114 x 162 ) mm = ( 4.49 x 6.38 ) in - 'C7' => array( 229.606, 323.150), // = ( 81 x 114 ) mm = ( 3.19 x 4.49 ) in - 'C8' => array( 161.575, 229.606), // = ( 57 x 81 ) mm = ( 2.24 x 3.19 ) in - 'C9' => array( 113.386, 161.575), // = ( 40 x 57 ) mm = ( 1.57 x 2.24 ) in - 'C10' => array( 79.370, 113.386), // = ( 28 x 40 ) mm = ( 1.10 x 1.57 ) in - 'C11' => array( 56.693, 79.370), // = ( 20 x 28 ) mm = ( 0.79 x 1.10 ) in - 'C12' => array( 39.685, 56.693), // = ( 14 x 20 ) mm = ( 0.55 x 0.79 ) in - 'C76' => array( 229.606, 459.213), // = ( 81 x 162 ) mm = ( 3.19 x 6.38 ) in - 'DL' => array( 311.811, 623.622), // = ( 110 x 220 ) mm = ( 4.33 x 8.66 ) in - 'DLE' => array( 323.150, 637.795), // = ( 114 x 225 ) mm = ( 4.49 x 8.86 ) in - 'DLX' => array( 340.158, 666.142), // = ( 120 x 235 ) mm = ( 4.72 x 9.25 ) in - 'DLP' => array( 280.630, 595.276), // = ( 99 x 210 ) mm = ( 3.90 x 8.27 ) in (A4/3) + 'C0' => [2599.370, 3676.535], // = ( 917 x 1297 ) mm = ( 36.10 x 51.06 ) in + 'C1' => [1836.850, 2599.370], // = ( 648 x 917 ) mm = ( 25.51 x 36.10 ) in + 'C2' => [1298.268, 1836.850], // = ( 458 x 648 ) mm = ( 18.03 x 25.51 ) in + 'C3' => [918.425, 1298.268], // = ( 324 x 458 ) mm = ( 12.76 x 18.03 ) in + 'C4' => [649.134, 918.425], // = ( 229 x 324 ) mm = ( 9.02 x 12.76 ) in + 'C5' => [459.213, 649.134], // = ( 162 x 229 ) mm = ( 6.38 x 9.02 ) in + 'C6' => [323.150, 459.213], // = ( 114 x 162 ) mm = ( 4.49 x 6.38 ) in + 'C7' => [229.606, 323.150], // = ( 81 x 114 ) mm = ( 3.19 x 4.49 ) in + 'C8' => [161.575, 229.606], // = ( 57 x 81 ) mm = ( 2.24 x 3.19 ) in + 'C9' => [113.386, 161.575], // = ( 40 x 57 ) mm = ( 1.57 x 2.24 ) in + 'C10' => [79.370, 113.386], // = ( 28 x 40 ) mm = ( 1.10 x 1.57 ) in + 'C11' => [56.693, 79.370], // = ( 20 x 28 ) mm = ( 0.79 x 1.10 ) in + 'C12' => [39.685, 56.693], // = ( 14 x 20 ) mm = ( 0.55 x 0.79 ) in + 'C76' => [229.606, 459.213], // = ( 81 x 162 ) mm = ( 3.19 x 6.38 ) in + 'DL' => [311.811, 623.622], // = ( 110 x 220 ) mm = ( 4.33 x 8.66 ) in + 'DLE' => [323.150, 637.795], // = ( 114 x 225 ) mm = ( 4.49 x 8.86 ) in + 'DLX' => [340.158, 666.142], // = ( 120 x 235 ) mm = ( 4.72 x 9.25 ) in + 'DLP' => [280.630, 595.276], // = ( 99 x 210 ) mm = ( 3.90 x 8.27 ) in (A4/3) // SIS 014711 E Series - 'E0' => array( 2491.654, 3517.795), // = ( 879 x 1241 ) mm = ( 34.61 x 48.86 ) in - 'E1' => array( 1757.480, 2491.654), // = ( 620 x 879 ) mm = ( 24.41 x 34.61 ) in - 'E2' => array( 1247.244, 1757.480), // = ( 440 x 620 ) mm = ( 17.32 x 24.41 ) in - 'E3' => array( 878.740, 1247.244), // = ( 310 x 440 ) mm = ( 12.20 x 17.32 ) in - 'E4' => array( 623.622, 878.740), // = ( 220 x 310 ) mm = ( 8.66 x 12.20 ) in - 'E5' => array( 439.370, 623.622), // = ( 155 x 220 ) mm = ( 6.10 x 8.66 ) in - 'E6' => array( 311.811, 439.370), // = ( 110 x 155 ) mm = ( 4.33 x 6.10 ) in - 'E7' => array( 221.102, 311.811), // = ( 78 x 110 ) mm = ( 3.07 x 4.33 ) in - 'E8' => array( 155.906, 221.102), // = ( 55 x 78 ) mm = ( 2.17 x 3.07 ) in - 'E9' => array( 110.551, 155.906), // = ( 39 x 55 ) mm = ( 1.54 x 2.17 ) in - 'E10' => array( 76.535, 110.551), // = ( 27 x 39 ) mm = ( 1.06 x 1.54 ) in - 'E11' => array( 53.858, 76.535), // = ( 19 x 27 ) mm = ( 0.75 x 1.06 ) in - 'E12' => array( 36.850, 53.858), // = ( 13 x 19 ) mm = ( 0.51 x 0.75 ) in + 'E0' => [2491.654, 3517.795], // = ( 879 x 1241 ) mm = ( 34.61 x 48.86 ) in + 'E1' => [1757.480, 2491.654], // = ( 620 x 879 ) mm = ( 24.41 x 34.61 ) in + 'E2' => [1247.244, 1757.480], // = ( 440 x 620 ) mm = ( 17.32 x 24.41 ) in + 'E3' => [878.740, 1247.244], // = ( 310 x 440 ) mm = ( 12.20 x 17.32 ) in + 'E4' => [623.622, 878.740], // = ( 220 x 310 ) mm = ( 8.66 x 12.20 ) in + 'E5' => [439.370, 623.622], // = ( 155 x 220 ) mm = ( 6.10 x 8.66 ) in + 'E6' => [311.811, 439.370], // = ( 110 x 155 ) mm = ( 4.33 x 6.10 ) in + 'E7' => [221.102, 311.811], // = ( 78 x 110 ) mm = ( 3.07 x 4.33 ) in + 'E8' => [155.906, 221.102], // = ( 55 x 78 ) mm = ( 2.17 x 3.07 ) in + 'E9' => [110.551, 155.906], // = ( 39 x 55 ) mm = ( 1.54 x 2.17 ) in + 'E10' => [76.535, 110.551], // = ( 27 x 39 ) mm = ( 1.06 x 1.54 ) in + 'E11' => [53.858, 76.535], // = ( 19 x 27 ) mm = ( 0.75 x 1.06 ) in + 'E12' => [36.850, 53.858], // = ( 13 x 19 ) mm = ( 0.51 x 0.75 ) in // SIS 014711 G Series - 'G0' => array( 2715.591, 3838.110), // = ( 958 x 1354 ) mm = ( 37.72 x 53.31 ) in - 'G1' => array( 1919.055, 2715.591), // = ( 677 x 958 ) mm = ( 26.65 x 37.72 ) in - 'G2' => array( 1357.795, 1919.055), // = ( 479 x 677 ) mm = ( 18.86 x 26.65 ) in - 'G3' => array( 958.110, 1357.795), // = ( 338 x 479 ) mm = ( 13.31 x 18.86 ) in - 'G4' => array( 677.480, 958.110), // = ( 239 x 338 ) mm = ( 9.41 x 13.31 ) in - 'G5' => array( 479.055, 677.480), // = ( 169 x 239 ) mm = ( 6.65 x 9.41 ) in - 'G6' => array( 337.323, 479.055), // = ( 119 x 169 ) mm = ( 4.69 x 6.65 ) in - 'G7' => array( 238.110, 337.323), // = ( 84 x 119 ) mm = ( 3.31 x 4.69 ) in - 'G8' => array( 167.244, 238.110), // = ( 59 x 84 ) mm = ( 2.32 x 3.31 ) in - 'G9' => array( 119.055, 167.244), // = ( 42 x 59 ) mm = ( 1.65 x 2.32 ) in - 'G10' => array( 82.205, 119.055), // = ( 29 x 42 ) mm = ( 1.14 x 1.65 ) in - 'G11' => array( 59.528, 82.205), // = ( 21 x 29 ) mm = ( 0.83 x 1.14 ) in - 'G12' => array( 39.685, 59.528), // = ( 14 x 21 ) mm = ( 0.55 x 0.83 ) in + 'G0' => [2715.591, 3838.110], // = ( 958 x 1354 ) mm = ( 37.72 x 53.31 ) in + 'G1' => [1919.055, 2715.591], // = ( 677 x 958 ) mm = ( 26.65 x 37.72 ) in + 'G2' => [1357.795, 1919.055], // = ( 479 x 677 ) mm = ( 18.86 x 26.65 ) in + 'G3' => [958.110, 1357.795], // = ( 338 x 479 ) mm = ( 13.31 x 18.86 ) in + 'G4' => [677.480, 958.110], // = ( 239 x 338 ) mm = ( 9.41 x 13.31 ) in + 'G5' => [479.055, 677.480], // = ( 169 x 239 ) mm = ( 6.65 x 9.41 ) in + 'G6' => [337.323, 479.055], // = ( 119 x 169 ) mm = ( 4.69 x 6.65 ) in + 'G7' => [238.110, 337.323], // = ( 84 x 119 ) mm = ( 3.31 x 4.69 ) in + 'G8' => [167.244, 238.110], // = ( 59 x 84 ) mm = ( 2.32 x 3.31 ) in + 'G9' => [119.055, 167.244], // = ( 42 x 59 ) mm = ( 1.65 x 2.32 ) in + 'G10' => [82.205, 119.055], // = ( 29 x 42 ) mm = ( 1.14 x 1.65 ) in + 'G11' => [59.528, 82.205], // = ( 21 x 29 ) mm = ( 0.83 x 1.14 ) in + 'G12' => [39.685, 59.528], // = ( 14 x 21 ) mm = ( 0.55 x 0.83 ) in // ISO Press - 'RA0' => array( 2437.795, 3458.268), // = ( 860 x 1220 ) mm = ( 33.86 x 48.03 ) in - 'RA1' => array( 1729.134, 2437.795), // = ( 610 x 860 ) mm = ( 24.02 x 33.86 ) in - 'RA2' => array( 1218.898, 1729.134), // = ( 430 x 610 ) mm = ( 16.93 x 24.02 ) in - 'RA3' => array( 864.567, 1218.898), // = ( 305 x 430 ) mm = ( 12.01 x 16.93 ) in - 'RA4' => array( 609.449, 864.567), // = ( 215 x 305 ) mm = ( 8.46 x 12.01 ) in - 'SRA0' => array( 2551.181, 3628.346), // = ( 900 x 1280 ) mm = ( 35.43 x 50.39 ) in - 'SRA1' => array( 1814.173, 2551.181), // = ( 640 x 900 ) mm = ( 25.20 x 35.43 ) in - 'SRA2' => array( 1275.591, 1814.173), // = ( 450 x 640 ) mm = ( 17.72 x 25.20 ) in - 'SRA3' => array( 907.087, 1275.591), // = ( 320 x 450 ) mm = ( 12.60 x 17.72 ) in - 'SRA4' => array( 637.795, 907.087), // = ( 225 x 320 ) mm = ( 8.86 x 12.60 ) in + 'RA0' => [2437.795, 3458.268], // = ( 860 x 1220 ) mm = ( 33.86 x 48.03 ) in + 'RA1' => [1729.134, 2437.795], // = ( 610 x 860 ) mm = ( 24.02 x 33.86 ) in + 'RA2' => [1218.898, 1729.134], // = ( 430 x 610 ) mm = ( 16.93 x 24.02 ) in + 'RA3' => [864.567, 1218.898], // = ( 305 x 430 ) mm = ( 12.01 x 16.93 ) in + 'RA4' => [609.449, 864.567], // = ( 215 x 305 ) mm = ( 8.46 x 12.01 ) in + 'SRA0' => [2551.181, 3628.346], // = ( 900 x 1280 ) mm = ( 35.43 x 50.39 ) in + 'SRA1' => [1814.173, 2551.181], // = ( 640 x 900 ) mm = ( 25.20 x 35.43 ) in + 'SRA2' => [1275.591, 1814.173], // = ( 450 x 640 ) mm = ( 17.72 x 25.20 ) in + 'SRA3' => [907.087, 1275.591], // = ( 320 x 450 ) mm = ( 12.60 x 17.72 ) in + 'SRA4' => [637.795, 907.087], // = ( 225 x 320 ) mm = ( 8.86 x 12.60 ) in // German DIN 476 - '4A0' => array( 4767.874, 6740.787), // = ( 1682 x 2378 ) mm = ( 66.22 x 93.62 ) in - '2A0' => array( 3370.394, 4767.874), // = ( 1189 x 1682 ) mm = ( 46.81 x 66.22 ) in + '4A0' => [4767.874, 6740.787], // = ( 1682 x 2378 ) mm = ( 66.22 x 93.62 ) in + '2A0' => [3370.394, 4767.874], // = ( 1189 x 1682 ) mm = ( 46.81 x 66.22 ) in // Variations on the ISO Standard - 'A2_EXTRA' => array( 1261.417, 1754.646), // = ( 445 x 619 ) mm = ( 17.52 x 24.37 ) in - 'A3+' => array( 932.598, 1369.134), // = ( 329 x 483 ) mm = ( 12.95 x 19.02 ) in - 'A3_EXTRA' => array( 912.756, 1261.417), // = ( 322 x 445 ) mm = ( 12.68 x 17.52 ) in - 'A3_SUPER' => array( 864.567, 1440.000), // = ( 305 x 508 ) mm = ( 12.01 x 20.00 ) in - 'SUPER_A3' => array( 864.567, 1380.472), // = ( 305 x 487 ) mm = ( 12.01 x 19.17 ) in - 'A4_EXTRA' => array( 666.142, 912.756), // = ( 235 x 322 ) mm = ( 9.25 x 12.68 ) in - 'A4_SUPER' => array( 649.134, 912.756), // = ( 229 x 322 ) mm = ( 9.02 x 12.68 ) in - 'SUPER_A4' => array( 643.465, 1009.134), // = ( 227 x 356 ) mm = ( 8.94 x 14.02 ) in - 'A4_LONG' => array( 595.276, 986.457), // = ( 210 x 348 ) mm = ( 8.27 x 13.70 ) in - 'F4' => array( 595.276, 935.433), // = ( 210 x 330 ) mm = ( 8.27 x 12.99 ) in - 'SO_B5_EXTRA' => array( 572.598, 782.362), // = ( 202 x 276 ) mm = ( 7.95 x 10.87 ) in - 'A5_EXTRA' => array( 490.394, 666.142), // = ( 173 x 235 ) mm = ( 6.81 x 9.25 ) in + 'A2_EXTRA' => [1261.417, 1754.646], // = ( 445 x 619 ) mm = ( 17.52 x 24.37 ) in + 'A3+' => [932.598, 1369.134], // = ( 329 x 483 ) mm = ( 12.95 x 19.02 ) in + 'A3_EXTRA' => [912.756, 1261.417], // = ( 322 x 445 ) mm = ( 12.68 x 17.52 ) in + 'A3_SUPER' => [864.567, 1440.000], // = ( 305 x 508 ) mm = ( 12.01 x 20.00 ) in + 'SUPER_A3' => [864.567, 1380.472], // = ( 305 x 487 ) mm = ( 12.01 x 19.17 ) in + 'A4_EXTRA' => [666.142, 912.756], // = ( 235 x 322 ) mm = ( 9.25 x 12.68 ) in + 'A4_SUPER' => [649.134, 912.756], // = ( 229 x 322 ) mm = ( 9.02 x 12.68 ) in + 'SUPER_A4' => [643.465, 1009.134], // = ( 227 x 356 ) mm = ( 8.94 x 14.02 ) in + 'A4_LONG' => [595.276, 986.457], // = ( 210 x 348 ) mm = ( 8.27 x 13.70 ) in + 'F4' => [595.276, 935.433], // = ( 210 x 330 ) mm = ( 8.27 x 12.99 ) in + 'SO_B5_EXTRA' => [572.598, 782.362], // = ( 202 x 276 ) mm = ( 7.95 x 10.87 ) in + 'A5_EXTRA' => [490.394, 666.142], // = ( 173 x 235 ) mm = ( 6.81 x 9.25 ) in // ANSI Series - 'ANSI_E' => array( 2448.000, 3168.000), // = ( 864 x 1118 ) mm = ( 34.00 x 44.00 ) in - 'ANSI_D' => array( 1584.000, 2448.000), // = ( 559 x 864 ) mm = ( 22.00 x 34.00 ) in - 'ANSI_C' => array( 1224.000, 1584.000), // = ( 432 x 559 ) mm = ( 17.00 x 22.00 ) in - 'ANSI_B' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in - 'ANSI_A' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in + 'ANSI_E' => [2448.000, 3168.000], // = ( 864 x 1118 ) mm = ( 34.00 x 44.00 ) in + 'ANSI_D' => [1584.000, 2448.000], // = ( 559 x 864 ) mm = ( 22.00 x 34.00 ) in + 'ANSI_C' => [1224.000, 1584.000], // = ( 432 x 559 ) mm = ( 17.00 x 22.00 ) in + 'ANSI_B' => [792.000, 1224.000], // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in + 'ANSI_A' => [612.000, 792.000], // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in // Traditional 'Loose' North American Paper Sizes - 'USLEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in - 'LEDGER' => array( 1224.000, 792.000), // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in - 'ORGANIZERK' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in - 'BIBLE' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in - 'USTABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in - 'TABLOID' => array( 792.000, 1224.000), // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in - 'ORGANIZERM' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in - 'USLETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in - 'LETTER' => array( 612.000, 792.000), // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in - 'USLEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in - 'LEGAL' => array( 612.000, 1008.000), // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in - 'GOVERNMENTLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in - 'GLETTER' => array( 576.000, 756.000), // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in - 'JUNIORLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in - 'JLEGAL' => array( 576.000, 360.000), // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in + 'USLEDGER' => [1224.000, 792.000], // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in + 'LEDGER' => [1224.000, 792.000], // = ( 432 x 279 ) mm = ( 17.00 x 11.00 ) in + 'ORGANIZERK' => [792.000, 1224.000], // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in + 'BIBLE' => [792.000, 1224.000], // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in + 'USTABLOID' => [792.000, 1224.000], // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in + 'TABLOID' => [792.000, 1224.000], // = ( 279 x 432 ) mm = ( 11.00 x 17.00 ) in + 'ORGANIZERM' => [612.000, 792.000], // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in + 'USLETTER' => [612.000, 792.000], // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in + 'LETTER' => [612.000, 792.000], // = ( 216 x 279 ) mm = ( 8.50 x 11.00 ) in + 'USLEGAL' => [612.000, 1008.000], // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in + 'LEGAL' => [612.000, 1008.000], // = ( 216 x 356 ) mm = ( 8.50 x 14.00 ) in + 'GOVERNMENTLETTER' => [576.000, 756.000], // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in + 'GLETTER' => [576.000, 756.000], // = ( 203 x 267 ) mm = ( 8.00 x 10.50 ) in + 'JUNIORLEGAL' => [576.000, 360.000], // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in + 'JLEGAL' => [576.000, 360.000], // = ( 203 x 127 ) mm = ( 8.00 x 5.00 ) in // Other North American Paper Sizes - 'QUADDEMY' => array( 2520.000, 3240.000), // = ( 889 x 1143 ) mm = ( 35.00 x 45.00 ) in - 'SUPER_B' => array( 936.000, 1368.000), // = ( 330 x 483 ) mm = ( 13.00 x 19.00 ) in - 'QUARTO' => array( 648.000, 792.000), // = ( 229 x 279 ) mm = ( 9.00 x 11.00 ) in - 'GOVERNMENTLEGAL' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in - 'FOLIO' => array( 612.000, 936.000), // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in - 'MONARCH' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in - 'EXECUTIVE' => array( 522.000, 756.000), // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in - 'ORGANIZERL' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in - 'STATEMENT' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in - 'MEMO' => array( 396.000, 612.000), // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in - 'FOOLSCAP' => array( 595.440, 936.000), // = ( 210 x 330 ) mm = ( 8.27 x 13.00 ) in - 'COMPACT' => array( 306.000, 486.000), // = ( 108 x 171 ) mm = ( 4.25 x 6.75 ) in - 'ORGANIZERJ' => array( 198.000, 360.000), // = ( 70 x 127 ) mm = ( 2.75 x 5.00 ) in + 'QUADDEMY' => [2520.000, 3240.000], // = ( 889 x 1143 ) mm = ( 35.00 x 45.00 ) in + 'SUPER_B' => [936.000, 1368.000], // = ( 330 x 483 ) mm = ( 13.00 x 19.00 ) in + 'QUARTO' => [648.000, 792.000], // = ( 229 x 279 ) mm = ( 9.00 x 11.00 ) in + 'GOVERNMENTLEGAL' => [612.000, 936.000], // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in + 'FOLIO' => [612.000, 936.000], // = ( 216 x 330 ) mm = ( 8.50 x 13.00 ) in + 'MONARCH' => [522.000, 756.000], // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in + 'EXECUTIVE' => [522.000, 756.000], // = ( 184 x 267 ) mm = ( 7.25 x 10.50 ) in + 'ORGANIZERL' => [396.000, 612.000], // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in + 'STATEMENT' => [396.000, 612.000], // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in + 'MEMO' => [396.000, 612.000], // = ( 140 x 216 ) mm = ( 5.50 x 8.50 ) in + 'FOOLSCAP' => [595.440, 936.000], // = ( 210 x 330 ) mm = ( 8.27 x 13.00 ) in + 'COMPACT' => [306.000, 486.000], // = ( 108 x 171 ) mm = ( 4.25 x 6.75 ) in + 'ORGANIZERJ' => [198.000, 360.000], // = ( 70 x 127 ) mm = ( 2.75 x 5.00 ) in // Canadian standard CAN 2-9.60M - 'P1' => array( 1587.402, 2437.795), // = ( 560 x 860 ) mm = ( 22.05 x 33.86 ) in - 'P2' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in - 'P3' => array( 793.701, 1218.898), // = ( 280 x 430 ) mm = ( 11.02 x 16.93 ) in - 'P4' => array( 609.449, 793.701), // = ( 215 x 280 ) mm = ( 8.46 x 11.02 ) in - 'P5' => array( 396.850, 609.449), // = ( 140 x 215 ) mm = ( 5.51 x 8.46 ) in - 'P6' => array( 303.307, 396.850), // = ( 107 x 140 ) mm = ( 4.21 x 5.51 ) in + 'P1' => [1587.402, 2437.795], // = ( 560 x 860 ) mm = ( 22.05 x 33.86 ) in + 'P2' => [1218.898, 1587.402], // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in + 'P3' => [793.701, 1218.898], // = ( 280 x 430 ) mm = ( 11.02 x 16.93 ) in + 'P4' => [609.449, 793.701], // = ( 215 x 280 ) mm = ( 8.46 x 11.02 ) in + 'P5' => [396.850, 609.449], // = ( 140 x 215 ) mm = ( 5.51 x 8.46 ) in + 'P6' => [303.307, 396.850], // = ( 107 x 140 ) mm = ( 4.21 x 5.51 ) in // North American Architectural Sizes - 'ARCH_E' => array( 2592.000, 3456.000), // = ( 914 x 1219 ) mm = ( 36.00 x 48.00 ) in - 'ARCH_E1' => array( 2160.000, 3024.000), // = ( 762 x 1067 ) mm = ( 30.00 x 42.00 ) in - 'ARCH_D' => array( 1728.000, 2592.000), // = ( 610 x 914 ) mm = ( 24.00 x 36.00 ) in - 'BROADSHEET' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in - 'ARCH_C' => array( 1296.000, 1728.000), // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in - 'ARCH_B' => array( 864.000, 1296.000), // = ( 305 x 457 ) mm = ( 12.00 x 18.00 ) in - 'ARCH_A' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in + 'ARCH_E' => [2592.000, 3456.000], // = ( 914 x 1219 ) mm = ( 36.00 x 48.00 ) in + 'ARCH_E1' => [2160.000, 3024.000], // = ( 762 x 1067 ) mm = ( 30.00 x 42.00 ) in + 'ARCH_D' => [1728.000, 2592.000], // = ( 610 x 914 ) mm = ( 24.00 x 36.00 ) in + 'BROADSHEET' => [1296.000, 1728.000], // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in + 'ARCH_C' => [1296.000, 1728.000], // = ( 457 x 610 ) mm = ( 18.00 x 24.00 ) in + 'ARCH_B' => [864.000, 1296.000], // = ( 305 x 457 ) mm = ( 12.00 x 18.00 ) in + 'ARCH_A' => [648.000, 864.000], // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in // -- North American Envelope Sizes // - Announcement Envelopes - 'ANNENV_A2' => array( 314.640, 414.000), // = ( 111 x 146 ) mm = ( 4.37 x 5.75 ) in - 'ANNENV_A6' => array( 342.000, 468.000), // = ( 121 x 165 ) mm = ( 4.75 x 6.50 ) in - 'ANNENV_A7' => array( 378.000, 522.000), // = ( 133 x 184 ) mm = ( 5.25 x 7.25 ) in - 'ANNENV_A8' => array( 396.000, 584.640), // = ( 140 x 206 ) mm = ( 5.50 x 8.12 ) in - 'ANNENV_A10' => array( 450.000, 692.640), // = ( 159 x 244 ) mm = ( 6.25 x 9.62 ) in - 'ANNENV_SLIM' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in + 'ANNENV_A2' => [314.640, 414.000], // = ( 111 x 146 ) mm = ( 4.37 x 5.75 ) in + 'ANNENV_A6' => [342.000, 468.000], // = ( 121 x 165 ) mm = ( 4.75 x 6.50 ) in + 'ANNENV_A7' => [378.000, 522.000], // = ( 133 x 184 ) mm = ( 5.25 x 7.25 ) in + 'ANNENV_A8' => [396.000, 584.640], // = ( 140 x 206 ) mm = ( 5.50 x 8.12 ) in + 'ANNENV_A10' => [450.000, 692.640], // = ( 159 x 244 ) mm = ( 6.25 x 9.62 ) in + 'ANNENV_SLIM' => [278.640, 638.640], // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in // - Commercial Envelopes - 'COMMENV_N6_1/4' => array( 252.000, 432.000), // = ( 89 x 152 ) mm = ( 3.50 x 6.00 ) in - 'COMMENV_N6_3/4' => array( 260.640, 468.000), // = ( 92 x 165 ) mm = ( 3.62 x 6.50 ) in - 'COMMENV_N8' => array( 278.640, 540.000), // = ( 98 x 191 ) mm = ( 3.87 x 7.50 ) in - 'COMMENV_N9' => array( 278.640, 638.640), // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in - 'COMMENV_N10' => array( 296.640, 684.000), // = ( 105 x 241 ) mm = ( 4.12 x 9.50 ) in - 'COMMENV_N11' => array( 324.000, 746.640), // = ( 114 x 263 ) mm = ( 4.50 x 10.37 ) in - 'COMMENV_N12' => array( 342.000, 792.000), // = ( 121 x 279 ) mm = ( 4.75 x 11.00 ) in - 'COMMENV_N14' => array( 360.000, 828.000), // = ( 127 x 292 ) mm = ( 5.00 x 11.50 ) in + 'COMMENV_N6_1/4' => [252.000, 432.000], // = ( 89 x 152 ) mm = ( 3.50 x 6.00 ) in + 'COMMENV_N6_3/4' => [260.640, 468.000], // = ( 92 x 165 ) mm = ( 3.62 x 6.50 ) in + 'COMMENV_N8' => [278.640, 540.000], // = ( 98 x 191 ) mm = ( 3.87 x 7.50 ) in + 'COMMENV_N9' => [278.640, 638.640], // = ( 98 x 225 ) mm = ( 3.87 x 8.87 ) in + 'COMMENV_N10' => [296.640, 684.000], // = ( 105 x 241 ) mm = ( 4.12 x 9.50 ) in + 'COMMENV_N11' => [324.000, 746.640], // = ( 114 x 263 ) mm = ( 4.50 x 10.37 ) in + 'COMMENV_N12' => [342.000, 792.000], // = ( 121 x 279 ) mm = ( 4.75 x 11.00 ) in + 'COMMENV_N14' => [360.000, 828.000], // = ( 127 x 292 ) mm = ( 5.00 x 11.50 ) in // - Catalogue Envelopes - 'CATENV_N1' => array( 432.000, 648.000), // = ( 152 x 229 ) mm = ( 6.00 x 9.00 ) in - 'CATENV_N1_3/4' => array( 468.000, 684.000), // = ( 165 x 241 ) mm = ( 6.50 x 9.50 ) in - 'CATENV_N2' => array( 468.000, 720.000), // = ( 165 x 254 ) mm = ( 6.50 x 10.00 ) in - 'CATENV_N3' => array( 504.000, 720.000), // = ( 178 x 254 ) mm = ( 7.00 x 10.00 ) in - 'CATENV_N6' => array( 540.000, 756.000), // = ( 191 x 267 ) mm = ( 7.50 x 10.50 ) in - 'CATENV_N7' => array( 576.000, 792.000), // = ( 203 x 279 ) mm = ( 8.00 x 11.00 ) in - 'CATENV_N8' => array( 594.000, 810.000), // = ( 210 x 286 ) mm = ( 8.25 x 11.25 ) in - 'CATENV_N9_1/2' => array( 612.000, 756.000), // = ( 216 x 267 ) mm = ( 8.50 x 10.50 ) in - 'CATENV_N9_3/4' => array( 630.000, 810.000), // = ( 222 x 286 ) mm = ( 8.75 x 11.25 ) in - 'CATENV_N10_1/2' => array( 648.000, 864.000), // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in - 'CATENV_N12_1/2' => array( 684.000, 900.000), // = ( 241 x 318 ) mm = ( 9.50 x 12.50 ) in - 'CATENV_N13_1/2' => array( 720.000, 936.000), // = ( 254 x 330 ) mm = ( 10.00 x 13.00 ) in - 'CATENV_N14_1/4' => array( 810.000, 882.000), // = ( 286 x 311 ) mm = ( 11.25 x 12.25 ) in - 'CATENV_N14_1/2' => array( 828.000, 1044.000), // = ( 292 x 368 ) mm = ( 11.50 x 14.50 ) in + 'CATENV_N1' => [432.000, 648.000], // = ( 152 x 229 ) mm = ( 6.00 x 9.00 ) in + 'CATENV_N1_3/4' => [468.000, 684.000], // = ( 165 x 241 ) mm = ( 6.50 x 9.50 ) in + 'CATENV_N2' => [468.000, 720.000], // = ( 165 x 254 ) mm = ( 6.50 x 10.00 ) in + 'CATENV_N3' => [504.000, 720.000], // = ( 178 x 254 ) mm = ( 7.00 x 10.00 ) in + 'CATENV_N6' => [540.000, 756.000], // = ( 191 x 267 ) mm = ( 7.50 x 10.50 ) in + 'CATENV_N7' => [576.000, 792.000], // = ( 203 x 279 ) mm = ( 8.00 x 11.00 ) in + 'CATENV_N8' => [594.000, 810.000], // = ( 210 x 286 ) mm = ( 8.25 x 11.25 ) in + 'CATENV_N9_1/2' => [612.000, 756.000], // = ( 216 x 267 ) mm = ( 8.50 x 10.50 ) in + 'CATENV_N9_3/4' => [630.000, 810.000], // = ( 222 x 286 ) mm = ( 8.75 x 11.25 ) in + 'CATENV_N10_1/2' => [648.000, 864.000], // = ( 229 x 305 ) mm = ( 9.00 x 12.00 ) in + 'CATENV_N12_1/2' => [684.000, 900.000], // = ( 241 x 318 ) mm = ( 9.50 x 12.50 ) in + 'CATENV_N13_1/2' => [720.000, 936.000], // = ( 254 x 330 ) mm = ( 10.00 x 13.00 ) in + 'CATENV_N14_1/4' => [810.000, 882.000], // = ( 286 x 311 ) mm = ( 11.25 x 12.25 ) in + 'CATENV_N14_1/2' => [828.000, 1044.000], // = ( 292 x 368 ) mm = ( 11.50 x 14.50 ) in // Japanese (JIS P 0138-61) Standard B-Series - 'JIS_B0' => array( 2919.685, 4127.244), // = ( 1030 x 1456 ) mm = ( 40.55 x 57.32 ) in - 'JIS_B1' => array( 2063.622, 2919.685), // = ( 728 x 1030 ) mm = ( 28.66 x 40.55 ) in - 'JIS_B2' => array( 1459.843, 2063.622), // = ( 515 x 728 ) mm = ( 20.28 x 28.66 ) in - 'JIS_B3' => array( 1031.811, 1459.843), // = ( 364 x 515 ) mm = ( 14.33 x 20.28 ) in - 'JIS_B4' => array( 728.504, 1031.811), // = ( 257 x 364 ) mm = ( 10.12 x 14.33 ) in - 'JIS_B5' => array( 515.906, 728.504), // = ( 182 x 257 ) mm = ( 7.17 x 10.12 ) in - 'JIS_B6' => array( 362.835, 515.906), // = ( 128 x 182 ) mm = ( 5.04 x 7.17 ) in - 'JIS_B7' => array( 257.953, 362.835), // = ( 91 x 128 ) mm = ( 3.58 x 5.04 ) in - 'JIS_B8' => array( 181.417, 257.953), // = ( 64 x 91 ) mm = ( 2.52 x 3.58 ) in - 'JIS_B9' => array( 127.559, 181.417), // = ( 45 x 64 ) mm = ( 1.77 x 2.52 ) in - 'JIS_B10' => array( 90.709, 127.559), // = ( 32 x 45 ) mm = ( 1.26 x 1.77 ) in - 'JIS_B11' => array( 62.362, 90.709), // = ( 22 x 32 ) mm = ( 0.87 x 1.26 ) in - 'JIS_B12' => array( 45.354, 62.362), // = ( 16 x 22 ) mm = ( 0.63 x 0.87 ) in + 'JIS_B0' => [2919.685, 4127.244], // = ( 1030 x 1456 ) mm = ( 40.55 x 57.32 ) in + 'JIS_B1' => [2063.622, 2919.685], // = ( 728 x 1030 ) mm = ( 28.66 x 40.55 ) in + 'JIS_B2' => [1459.843, 2063.622], // = ( 515 x 728 ) mm = ( 20.28 x 28.66 ) in + 'JIS_B3' => [1031.811, 1459.843], // = ( 364 x 515 ) mm = ( 14.33 x 20.28 ) in + 'JIS_B4' => [728.504, 1031.811], // = ( 257 x 364 ) mm = ( 10.12 x 14.33 ) in + 'JIS_B5' => [515.906, 728.504], // = ( 182 x 257 ) mm = ( 7.17 x 10.12 ) in + 'JIS_B6' => [362.835, 515.906], // = ( 128 x 182 ) mm = ( 5.04 x 7.17 ) in + 'JIS_B7' => [257.953, 362.835], // = ( 91 x 128 ) mm = ( 3.58 x 5.04 ) in + 'JIS_B8' => [181.417, 257.953], // = ( 64 x 91 ) mm = ( 2.52 x 3.58 ) in + 'JIS_B9' => [127.559, 181.417], // = ( 45 x 64 ) mm = ( 1.77 x 2.52 ) in + 'JIS_B10' => [90.709, 127.559], // = ( 32 x 45 ) mm = ( 1.26 x 1.77 ) in + 'JIS_B11' => [62.362, 90.709], // = ( 22 x 32 ) mm = ( 0.87 x 1.26 ) in + 'JIS_B12' => [45.354, 62.362], // = ( 16 x 22 ) mm = ( 0.63 x 0.87 ) in // PA Series - 'PA0' => array( 2381.102, 3174.803), // = ( 840 x 1120 ) mm = ( 33.07 x 44.09 ) in - 'PA1' => array( 1587.402, 2381.102), // = ( 560 x 840 ) mm = ( 22.05 x 33.07 ) in - 'PA2' => array( 1190.551, 1587.402), // = ( 420 x 560 ) mm = ( 16.54 x 22.05 ) in - 'PA3' => array( 793.701, 1190.551), // = ( 280 x 420 ) mm = ( 11.02 x 16.54 ) in - 'PA4' => array( 595.276, 793.701), // = ( 210 x 280 ) mm = ( 8.27 x 11.02 ) in - 'PA5' => array( 396.850, 595.276), // = ( 140 x 210 ) mm = ( 5.51 x 8.27 ) in - 'PA6' => array( 297.638, 396.850), // = ( 105 x 140 ) mm = ( 4.13 x 5.51 ) in - 'PA7' => array( 198.425, 297.638), // = ( 70 x 105 ) mm = ( 2.76 x 4.13 ) in - 'PA8' => array( 147.402, 198.425), // = ( 52 x 70 ) mm = ( 2.05 x 2.76 ) in - 'PA9' => array( 99.213, 147.402), // = ( 35 x 52 ) mm = ( 1.38 x 2.05 ) in - 'PA10' => array( 73.701, 99.213), // = ( 26 x 35 ) mm = ( 1.02 x 1.38 ) in + 'PA0' => [2381.102, 3174.803], // = ( 840 x 1120 ) mm = ( 33.07 x 44.09 ) in + 'PA1' => [1587.402, 2381.102], // = ( 560 x 840 ) mm = ( 22.05 x 33.07 ) in + 'PA2' => [1190.551, 1587.402], // = ( 420 x 560 ) mm = ( 16.54 x 22.05 ) in + 'PA3' => [793.701, 1190.551], // = ( 280 x 420 ) mm = ( 11.02 x 16.54 ) in + 'PA4' => [595.276, 793.701], // = ( 210 x 280 ) mm = ( 8.27 x 11.02 ) in + 'PA5' => [396.850, 595.276], // = ( 140 x 210 ) mm = ( 5.51 x 8.27 ) in + 'PA6' => [297.638, 396.850], // = ( 105 x 140 ) mm = ( 4.13 x 5.51 ) in + 'PA7' => [198.425, 297.638], // = ( 70 x 105 ) mm = ( 2.76 x 4.13 ) in + 'PA8' => [147.402, 198.425], // = ( 52 x 70 ) mm = ( 2.05 x 2.76 ) in + 'PA9' => [99.213, 147.402], // = ( 35 x 52 ) mm = ( 1.38 x 2.05 ) in + 'PA10' => [73.701, 99.213], // = ( 26 x 35 ) mm = ( 1.02 x 1.38 ) in // Standard Photographic Print Sizes - 'PASSPORT_PHOTO' => array( 99.213, 127.559), // = ( 35 x 45 ) mm = ( 1.38 x 1.77 ) in - 'E' => array( 233.858, 340.157), // = ( 82 x 120 ) mm = ( 3.25 x 4.72 ) in - 'L' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in - '3R' => array( 252.283, 360.000), // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in - 'KG' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in - '4R' => array( 289.134, 430.866), // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in - '4D' => array( 340.157, 430.866), // = ( 120 x 152 ) mm = ( 4.72 x 5.98 ) in - '2L' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in - '5R' => array( 360.000, 504.567), // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in - '8P' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in - '6R' => array( 430.866, 575.433), // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in - '6P' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in - '8R' => array( 575.433, 720.000), // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in - '6PW' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in - 'S8R' => array( 575.433, 864.567), // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in - '4P' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in - '10R' => array( 720.000, 864.567), // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in - '4PW' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in - 'S10R' => array( 720.000, 1080.000), // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in - '11R' => array( 790.866, 1009.134), // = ( 279 x 356 ) mm = ( 10.98 x 14.02 ) in - 'S11R' => array( 790.866, 1224.567), // = ( 279 x 432 ) mm = ( 10.98 x 17.01 ) in - '12R' => array( 864.567, 1080.000), // = ( 305 x 381 ) mm = ( 12.01 x 15.00 ) in - 'S12R' => array( 864.567, 1292.598), // = ( 305 x 456 ) mm = ( 12.01 x 17.95 ) in + 'PASSPORT_PHOTO' => [99.213, 127.559], // = ( 35 x 45 ) mm = ( 1.38 x 1.77 ) in + 'E' => [233.858, 340.157], // = ( 82 x 120 ) mm = ( 3.25 x 4.72 ) in + 'L' => [252.283, 360.000], // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in + '3R' => [252.283, 360.000], // = ( 89 x 127 ) mm = ( 3.50 x 5.00 ) in + 'KG' => [289.134, 430.866], // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in + '4R' => [289.134, 430.866], // = ( 102 x 152 ) mm = ( 4.02 x 5.98 ) in + '4D' => [340.157, 430.866], // = ( 120 x 152 ) mm = ( 4.72 x 5.98 ) in + '2L' => [360.000, 504.567], // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in + '5R' => [360.000, 504.567], // = ( 127 x 178 ) mm = ( 5.00 x 7.01 ) in + '8P' => [430.866, 575.433], // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in + '6R' => [430.866, 575.433], // = ( 152 x 203 ) mm = ( 5.98 x 7.99 ) in + '6P' => [575.433, 720.000], // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in + '8R' => [575.433, 720.000], // = ( 203 x 254 ) mm = ( 7.99 x 10.00 ) in + '6PW' => [575.433, 864.567], // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in + 'S8R' => [575.433, 864.567], // = ( 203 x 305 ) mm = ( 7.99 x 12.01 ) in + '4P' => [720.000, 864.567], // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in + '10R' => [720.000, 864.567], // = ( 254 x 305 ) mm = ( 10.00 x 12.01 ) in + '4PW' => [720.000, 1080.000], // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in + 'S10R' => [720.000, 1080.000], // = ( 254 x 381 ) mm = ( 10.00 x 15.00 ) in + '11R' => [790.866, 1009.134], // = ( 279 x 356 ) mm = ( 10.98 x 14.02 ) in + 'S11R' => [790.866, 1224.567], // = ( 279 x 432 ) mm = ( 10.98 x 17.01 ) in + '12R' => [864.567, 1080.000], // = ( 305 x 381 ) mm = ( 12.01 x 15.00 ) in + 'S12R' => [864.567, 1292.598], // = ( 305 x 456 ) mm = ( 12.01 x 17.95 ) in // Common Newspaper Sizes - 'NEWSPAPER_BROADSHEET' => array( 2125.984, 1700.787), // = ( 750 x 600 ) mm = ( 29.53 x 23.62 ) in - 'NEWSPAPER_BERLINER' => array( 1332.283, 892.913), // = ( 470 x 315 ) mm = ( 18.50 x 12.40 ) in - 'NEWSPAPER_TABLOID' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in - 'NEWSPAPER_COMPACT' => array( 1218.898, 793.701), // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in + 'NEWSPAPER_BROADSHEET' => [2125.984, 1700.787], // = ( 750 x 600 ) mm = ( 29.53 x 23.62 ) in + 'NEWSPAPER_BERLINER' => [1332.283, 892.913], // = ( 470 x 315 ) mm = ( 18.50 x 12.40 ) in + 'NEWSPAPER_TABLOID' => [1218.898, 793.701], // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in + 'NEWSPAPER_COMPACT' => [1218.898, 793.701], // = ( 430 x 280 ) mm = ( 16.93 x 11.02 ) in // Business Cards - 'CREDIT_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in - 'BUSINESS_CARD' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in - 'BUSINESS_CARD_ISO7810' => array( 153.014, 242.646), // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in - 'BUSINESS_CARD_ISO216' => array( 147.402, 209.764), // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in - 'BUSINESS_CARD_IT' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in - 'BUSINESS_CARD_UK' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in - 'BUSINESS_CARD_FR' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in - 'BUSINESS_CARD_DE' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in - 'BUSINESS_CARD_ES' => array( 155.906, 240.945), // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in - 'BUSINESS_CARD_CA' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in - 'BUSINESS_CARD_US' => array( 144.567, 252.283), // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in - 'BUSINESS_CARD_JP' => array( 155.906, 257.953), // = ( 55 x 91 ) mm = ( 2.17 x 3.58 ) in - 'BUSINESS_CARD_HK' => array( 153.071, 255.118), // = ( 54 x 90 ) mm = ( 2.13 x 3.54 ) in - 'BUSINESS_CARD_AU' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in - 'BUSINESS_CARD_DK' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in - 'BUSINESS_CARD_SE' => array( 155.906, 255.118), // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in - 'BUSINESS_CARD_RU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in - 'BUSINESS_CARD_CZ' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in - 'BUSINESS_CARD_FI' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in - 'BUSINESS_CARD_HU' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in - 'BUSINESS_CARD_IL' => array( 141.732, 255.118), // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in + 'CREDIT_CARD' => [153.014, 242.646], // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in + 'BUSINESS_CARD' => [153.014, 242.646], // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in + 'BUSINESS_CARD_ISO7810' => [153.014, 242.646], // = ( 54 x 86 ) mm = ( 2.13 x 3.37 ) in + 'BUSINESS_CARD_ISO216' => [147.402, 209.764], // = ( 52 x 74 ) mm = ( 2.05 x 2.91 ) in + 'BUSINESS_CARD_IT' => [155.906, 240.945], // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in + 'BUSINESS_CARD_UK' => [155.906, 240.945], // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in + 'BUSINESS_CARD_FR' => [155.906, 240.945], // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in + 'BUSINESS_CARD_DE' => [155.906, 240.945], // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in + 'BUSINESS_CARD_ES' => [155.906, 240.945], // = ( 55 x 85 ) mm = ( 2.17 x 3.35 ) in + 'BUSINESS_CARD_CA' => [144.567, 252.283], // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in + 'BUSINESS_CARD_US' => [144.567, 252.283], // = ( 51 x 89 ) mm = ( 2.01 x 3.50 ) in + 'BUSINESS_CARD_JP' => [155.906, 257.953], // = ( 55 x 91 ) mm = ( 2.17 x 3.58 ) in + 'BUSINESS_CARD_HK' => [153.071, 255.118], // = ( 54 x 90 ) mm = ( 2.13 x 3.54 ) in + 'BUSINESS_CARD_AU' => [155.906, 255.118], // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in + 'BUSINESS_CARD_DK' => [155.906, 255.118], // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in + 'BUSINESS_CARD_SE' => [155.906, 255.118], // = ( 55 x 90 ) mm = ( 2.17 x 3.54 ) in + 'BUSINESS_CARD_RU' => [141.732, 255.118], // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in + 'BUSINESS_CARD_CZ' => [141.732, 255.118], // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in + 'BUSINESS_CARD_FI' => [141.732, 255.118], // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in + 'BUSINESS_CARD_HU' => [141.732, 255.118], // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in + 'BUSINESS_CARD_IL' => [141.732, 255.118], // = ( 50 x 90 ) mm = ( 1.97 x 3.54 ) in // Billboards - '4SHEET' => array( 2880.000, 4320.000), // = ( 1016 x 1524 ) mm = ( 40.00 x 60.00 ) in - '6SHEET' => array( 3401.575, 5102.362), // = ( 1200 x 1800 ) mm = ( 47.24 x 70.87 ) in - '12SHEET' => array( 8640.000, 4320.000), // = ( 3048 x 1524 ) mm = (120.00 x 60.00 ) in - '16SHEET' => array( 5760.000, 8640.000), // = ( 2032 x 3048 ) mm = ( 80.00 x 120.00) in - '32SHEET' => array(11520.000, 8640.000), // = ( 4064 x 3048 ) mm = (160.00 x 120.00) in - '48SHEET' => array(17280.000, 8640.000), // = ( 6096 x 3048 ) mm = (240.00 x 120.00) in - '64SHEET' => array(23040.000, 8640.000), // = ( 8128 x 3048 ) mm = (320.00 x 120.00) in - '96SHEET' => array(34560.000, 8640.000), // = (12192 x 3048 ) mm = (480.00 x 120.00) in + '4SHEET' => [2880.000, 4320.000], // = ( 1016 x 1524 ) mm = ( 40.00 x 60.00 ) in + '6SHEET' => [3401.575, 5102.362], // = ( 1200 x 1800 ) mm = ( 47.24 x 70.87 ) in + '12SHEET' => [8640.000, 4320.000], // = ( 3048 x 1524 ) mm = (120.00 x 60.00 ) in + '16SHEET' => [5760.000, 8640.000], // = ( 2032 x 3048 ) mm = ( 80.00 x 120.00) in + '32SHEET' => [11520.000, 8640.000], // = ( 4064 x 3048 ) mm = (160.00 x 120.00) in + '48SHEET' => [17280.000, 8640.000], // = ( 6096 x 3048 ) mm = (240.00 x 120.00) in + '64SHEET' => [23040.000, 8640.000], // = ( 8128 x 3048 ) mm = (320.00 x 120.00) in + '96SHEET' => [34560.000, 8640.000], // = (12192 x 3048 ) mm = (480.00 x 120.00) in // -- Old European Sizes // - Old Imperial English Sizes - 'EN_EMPEROR' => array( 3456.000, 5184.000), // = ( 1219 x 1829 ) mm = ( 48.00 x 72.00 ) in - 'EN_ANTIQUARIAN' => array( 2232.000, 3816.000), // = ( 787 x 1346 ) mm = ( 31.00 x 53.00 ) in - 'EN_GRAND_EAGLE' => array( 2070.000, 3024.000), // = ( 730 x 1067 ) mm = ( 28.75 x 42.00 ) in - 'EN_DOUBLE_ELEPHANT' => array( 1926.000, 2880.000), // = ( 679 x 1016 ) mm = ( 26.75 x 40.00 ) in - 'EN_ATLAS' => array( 1872.000, 2448.000), // = ( 660 x 864 ) mm = ( 26.00 x 34.00 ) in - 'EN_COLOMBIER' => array( 1692.000, 2484.000), // = ( 597 x 876 ) mm = ( 23.50 x 34.50 ) in - 'EN_ELEPHANT' => array( 1656.000, 2016.000), // = ( 584 x 711 ) mm = ( 23.00 x 28.00 ) in - 'EN_DOUBLE_DEMY' => array( 1620.000, 2556.000), // = ( 572 x 902 ) mm = ( 22.50 x 35.50 ) in - 'EN_IMPERIAL' => array( 1584.000, 2160.000), // = ( 559 x 762 ) mm = ( 22.00 x 30.00 ) in - 'EN_PRINCESS' => array( 1548.000, 2016.000), // = ( 546 x 711 ) mm = ( 21.50 x 28.00 ) in - 'EN_CARTRIDGE' => array( 1512.000, 1872.000), // = ( 533 x 660 ) mm = ( 21.00 x 26.00 ) in - 'EN_DOUBLE_LARGE_POST' => array( 1512.000, 2376.000), // = ( 533 x 838 ) mm = ( 21.00 x 33.00 ) in - 'EN_ROYAL' => array( 1440.000, 1800.000), // = ( 508 x 635 ) mm = ( 20.00 x 25.00 ) in - 'EN_SHEET' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in - 'EN_HALF_POST' => array( 1404.000, 1692.000), // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in - 'EN_SUPER_ROYAL' => array( 1368.000, 1944.000), // = ( 483 x 686 ) mm = ( 19.00 x 27.00 ) in - 'EN_DOUBLE_POST' => array( 1368.000, 2196.000), // = ( 483 x 775 ) mm = ( 19.00 x 30.50 ) in - 'EN_MEDIUM' => array( 1260.000, 1656.000), // = ( 445 x 584 ) mm = ( 17.50 x 23.00 ) in - 'EN_DEMY' => array( 1260.000, 1620.000), // = ( 445 x 572 ) mm = ( 17.50 x 22.50 ) in - 'EN_LARGE_POST' => array( 1188.000, 1512.000), // = ( 419 x 533 ) mm = ( 16.50 x 21.00 ) in - 'EN_COPY_DRAUGHT' => array( 1152.000, 1440.000), // = ( 406 x 508 ) mm = ( 16.00 x 20.00 ) in - 'EN_POST' => array( 1116.000, 1386.000), // = ( 394 x 489 ) mm = ( 15.50 x 19.25 ) in - 'EN_CROWN' => array( 1080.000, 1440.000), // = ( 381 x 508 ) mm = ( 15.00 x 20.00 ) in - 'EN_PINCHED_POST' => array( 1062.000, 1332.000), // = ( 375 x 470 ) mm = ( 14.75 x 18.50 ) in - 'EN_BRIEF' => array( 972.000, 1152.000), // = ( 343 x 406 ) mm = ( 13.50 x 16.00 ) in - 'EN_FOOLSCAP' => array( 972.000, 1224.000), // = ( 343 x 432 ) mm = ( 13.50 x 17.00 ) in - 'EN_SMALL_FOOLSCAP' => array( 954.000, 1188.000), // = ( 337 x 419 ) mm = ( 13.25 x 16.50 ) in - 'EN_POTT' => array( 900.000, 1080.000), // = ( 318 x 381 ) mm = ( 12.50 x 15.00 ) in + 'EN_EMPEROR' => [3456.000, 5184.000], // = ( 1219 x 1829 ) mm = ( 48.00 x 72.00 ) in + 'EN_ANTIQUARIAN' => [2232.000, 3816.000], // = ( 787 x 1346 ) mm = ( 31.00 x 53.00 ) in + 'EN_GRAND_EAGLE' => [2070.000, 3024.000], // = ( 730 x 1067 ) mm = ( 28.75 x 42.00 ) in + 'EN_DOUBLE_ELEPHANT' => [1926.000, 2880.000], // = ( 679 x 1016 ) mm = ( 26.75 x 40.00 ) in + 'EN_ATLAS' => [1872.000, 2448.000], // = ( 660 x 864 ) mm = ( 26.00 x 34.00 ) in + 'EN_COLOMBIER' => [1692.000, 2484.000], // = ( 597 x 876 ) mm = ( 23.50 x 34.50 ) in + 'EN_ELEPHANT' => [1656.000, 2016.000], // = ( 584 x 711 ) mm = ( 23.00 x 28.00 ) in + 'EN_DOUBLE_DEMY' => [1620.000, 2556.000], // = ( 572 x 902 ) mm = ( 22.50 x 35.50 ) in + 'EN_IMPERIAL' => [1584.000, 2160.000], // = ( 559 x 762 ) mm = ( 22.00 x 30.00 ) in + 'EN_PRINCESS' => [1548.000, 2016.000], // = ( 546 x 711 ) mm = ( 21.50 x 28.00 ) in + 'EN_CARTRIDGE' => [1512.000, 1872.000], // = ( 533 x 660 ) mm = ( 21.00 x 26.00 ) in + 'EN_DOUBLE_LARGE_POST' => [1512.000, 2376.000], // = ( 533 x 838 ) mm = ( 21.00 x 33.00 ) in + 'EN_ROYAL' => [1440.000, 1800.000], // = ( 508 x 635 ) mm = ( 20.00 x 25.00 ) in + 'EN_SHEET' => [1404.000, 1692.000], // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in + 'EN_HALF_POST' => [1404.000, 1692.000], // = ( 495 x 597 ) mm = ( 19.50 x 23.50 ) in + 'EN_SUPER_ROYAL' => [1368.000, 1944.000], // = ( 483 x 686 ) mm = ( 19.00 x 27.00 ) in + 'EN_DOUBLE_POST' => [1368.000, 2196.000], // = ( 483 x 775 ) mm = ( 19.00 x 30.50 ) in + 'EN_MEDIUM' => [1260.000, 1656.000], // = ( 445 x 584 ) mm = ( 17.50 x 23.00 ) in + 'EN_DEMY' => [1260.000, 1620.000], // = ( 445 x 572 ) mm = ( 17.50 x 22.50 ) in + 'EN_LARGE_POST' => [1188.000, 1512.000], // = ( 419 x 533 ) mm = ( 16.50 x 21.00 ) in + 'EN_COPY_DRAUGHT' => [1152.000, 1440.000], // = ( 406 x 508 ) mm = ( 16.00 x 20.00 ) in + 'EN_POST' => [1116.000, 1386.000], // = ( 394 x 489 ) mm = ( 15.50 x 19.25 ) in + 'EN_CROWN' => [1080.000, 1440.000], // = ( 381 x 508 ) mm = ( 15.00 x 20.00 ) in + 'EN_PINCHED_POST' => [1062.000, 1332.000], // = ( 375 x 470 ) mm = ( 14.75 x 18.50 ) in + 'EN_BRIEF' => [972.000, 1152.000], // = ( 343 x 406 ) mm = ( 13.50 x 16.00 ) in + 'EN_FOOLSCAP' => [972.000, 1224.000], // = ( 343 x 432 ) mm = ( 13.50 x 17.00 ) in + 'EN_SMALL_FOOLSCAP' => [954.000, 1188.000], // = ( 337 x 419 ) mm = ( 13.25 x 16.50 ) in + 'EN_POTT' => [900.000, 1080.000], // = ( 318 x 381 ) mm = ( 12.50 x 15.00 ) in // - Old Imperial Belgian Sizes - 'BE_GRAND_AIGLE' => array( 1984.252, 2948.031), // = ( 700 x 1040 ) mm = ( 27.56 x 40.94 ) in - 'BE_COLOMBIER' => array( 1757.480, 2409.449), // = ( 620 x 850 ) mm = ( 24.41 x 33.46 ) in - 'BE_DOUBLE_CARRE' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in - 'BE_ELEPHANT' => array( 1746.142, 2182.677), // = ( 616 x 770 ) mm = ( 24.25 x 30.31 ) in - 'BE_PETIT_AIGLE' => array( 1700.787, 2381.102), // = ( 600 x 840 ) mm = ( 23.62 x 33.07 ) in - 'BE_GRAND_JESUS' => array( 1559.055, 2069.291), // = ( 550 x 730 ) mm = ( 21.65 x 28.74 ) in - 'BE_JESUS' => array( 1530.709, 2069.291), // = ( 540 x 730 ) mm = ( 21.26 x 28.74 ) in - 'BE_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in - 'BE_GRAND_MEDIAN' => array( 1303.937, 1714.961), // = ( 460 x 605 ) mm = ( 18.11 x 23.82 ) in - 'BE_DOUBLE_POSTE' => array( 1233.071, 1601.575), // = ( 435 x 565 ) mm = ( 17.13 x 22.24 ) in - 'BE_COQUILLE' => array( 1218.898, 1587.402), // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in - 'BE_PETIT_MEDIAN' => array( 1176.378, 1502.362), // = ( 415 x 530 ) mm = ( 16.34 x 20.87 ) in - 'BE_RUCHE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in - 'BE_PROPATRIA' => array( 977.953, 1218.898), // = ( 345 x 430 ) mm = ( 13.58 x 16.93 ) in - 'BE_LYS' => array( 898.583, 1125.354), // = ( 317 x 397 ) mm = ( 12.48 x 15.63 ) in - 'BE_POT' => array( 870.236, 1088.504), // = ( 307 x 384 ) mm = ( 12.09 x 15.12 ) in - 'BE_ROSETTE' => array( 765.354, 983.622), // = ( 270 x 347 ) mm = ( 10.63 x 13.66 ) in + 'BE_GRAND_AIGLE' => [1984.252, 2948.031], // = ( 700 x 1040 ) mm = ( 27.56 x 40.94 ) in + 'BE_COLOMBIER' => [1757.480, 2409.449], // = ( 620 x 850 ) mm = ( 24.41 x 33.46 ) in + 'BE_DOUBLE_CARRE' => [1757.480, 2607.874], // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in + 'BE_ELEPHANT' => [1746.142, 2182.677], // = ( 616 x 770 ) mm = ( 24.25 x 30.31 ) in + 'BE_PETIT_AIGLE' => [1700.787, 2381.102], // = ( 600 x 840 ) mm = ( 23.62 x 33.07 ) in + 'BE_GRAND_JESUS' => [1559.055, 2069.291], // = ( 550 x 730 ) mm = ( 21.65 x 28.74 ) in + 'BE_JESUS' => [1530.709, 2069.291], // = ( 540 x 730 ) mm = ( 21.26 x 28.74 ) in + 'BE_RAISIN' => [1417.323, 1842.520], // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in + 'BE_GRAND_MEDIAN' => [1303.937, 1714.961], // = ( 460 x 605 ) mm = ( 18.11 x 23.82 ) in + 'BE_DOUBLE_POSTE' => [1233.071, 1601.575], // = ( 435 x 565 ) mm = ( 17.13 x 22.24 ) in + 'BE_COQUILLE' => [1218.898, 1587.402], // = ( 430 x 560 ) mm = ( 16.93 x 22.05 ) in + 'BE_PETIT_MEDIAN' => [1176.378, 1502.362], // = ( 415 x 530 ) mm = ( 16.34 x 20.87 ) in + 'BE_RUCHE' => [1020.472, 1303.937], // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in + 'BE_PROPATRIA' => [977.953, 1218.898], // = ( 345 x 430 ) mm = ( 13.58 x 16.93 ) in + 'BE_LYS' => [898.583, 1125.354], // = ( 317 x 397 ) mm = ( 12.48 x 15.63 ) in + 'BE_POT' => [870.236, 1088.504], // = ( 307 x 384 ) mm = ( 12.09 x 15.12 ) in + 'BE_ROSETTE' => [765.354, 983.622], // = ( 270 x 347 ) mm = ( 10.63 x 13.66 ) in // - Old Imperial French Sizes - 'FR_UNIVERS' => array( 2834.646, 3685.039), // = ( 1000 x 1300 ) mm = ( 39.37 x 51.18 ) in - 'FR_DOUBLE_COLOMBIER' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in - 'FR_GRANDE_MONDE' => array( 2551.181, 3571.654), // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in - 'FR_DOUBLE_SOLEIL' => array( 2267.717, 3401.575), // = ( 800 x 1200 ) mm = ( 31.50 x 47.24 ) in - 'FR_DOUBLE_JESUS' => array( 2154.331, 3174.803), // = ( 760 x 1120 ) mm = ( 29.92 x 44.09 ) in - 'FR_GRAND_AIGLE' => array( 2125.984, 3004.724), // = ( 750 x 1060 ) mm = ( 29.53 x 41.73 ) in - 'FR_PETIT_AIGLE' => array( 1984.252, 2664.567), // = ( 700 x 940 ) mm = ( 27.56 x 37.01 ) in - 'FR_DOUBLE_RAISIN' => array( 1842.520, 2834.646), // = ( 650 x 1000 ) mm = ( 25.59 x 39.37 ) in - 'FR_JOURNAL' => array( 1842.520, 2664.567), // = ( 650 x 940 ) mm = ( 25.59 x 37.01 ) in - 'FR_COLOMBIER_AFFICHE' => array( 1785.827, 2551.181), // = ( 630 x 900 ) mm = ( 24.80 x 35.43 ) in - 'FR_DOUBLE_CAVALIER' => array( 1757.480, 2607.874), // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in - 'FR_CLOCHE' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in - 'FR_SOLEIL' => array( 1700.787, 2267.717), // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in - 'FR_DOUBLE_CARRE' => array( 1587.402, 2551.181), // = ( 560 x 900 ) mm = ( 22.05 x 35.43 ) in - 'FR_DOUBLE_COQUILLE' => array( 1587.402, 2494.488), // = ( 560 x 880 ) mm = ( 22.05 x 34.65 ) in - 'FR_JESUS' => array( 1587.402, 2154.331), // = ( 560 x 760 ) mm = ( 22.05 x 29.92 ) in - 'FR_RAISIN' => array( 1417.323, 1842.520), // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in - 'FR_CAVALIER' => array( 1303.937, 1757.480), // = ( 460 x 620 ) mm = ( 18.11 x 24.41 ) in - 'FR_DOUBLE_COURONNE' => array( 1303.937, 2040.945), // = ( 460 x 720 ) mm = ( 18.11 x 28.35 ) in - 'FR_CARRE' => array( 1275.591, 1587.402), // = ( 450 x 560 ) mm = ( 17.72 x 22.05 ) in - 'FR_COQUILLE' => array( 1247.244, 1587.402), // = ( 440 x 560 ) mm = ( 17.32 x 22.05 ) in - 'FR_DOUBLE_TELLIERE' => array( 1247.244, 1927.559), // = ( 440 x 680 ) mm = ( 17.32 x 26.77 ) in - 'FR_DOUBLE_CLOCHE' => array( 1133.858, 1700.787), // = ( 400 x 600 ) mm = ( 15.75 x 23.62 ) in - 'FR_DOUBLE_POT' => array( 1133.858, 1757.480), // = ( 400 x 620 ) mm = ( 15.75 x 24.41 ) in - 'FR_ECU' => array( 1133.858, 1474.016), // = ( 400 x 520 ) mm = ( 15.75 x 20.47 ) in - 'FR_COURONNE' => array( 1020.472, 1303.937), // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in - 'FR_TELLIERE' => array( 963.780, 1247.244), // = ( 340 x 440 ) mm = ( 13.39 x 17.32 ) in - 'FR_POT' => array( 878.740, 1133.858), // = ( 310 x 400 ) mm = ( 12.20 x 15.75 ) in + 'FR_UNIVERS' => [2834.646, 3685.039], // = ( 1000 x 1300 ) mm = ( 39.37 x 51.18 ) in + 'FR_DOUBLE_COLOMBIER' => [2551.181, 3571.654], // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in + 'FR_GRANDE_MONDE' => [2551.181, 3571.654], // = ( 900 x 1260 ) mm = ( 35.43 x 49.61 ) in + 'FR_DOUBLE_SOLEIL' => [2267.717, 3401.575], // = ( 800 x 1200 ) mm = ( 31.50 x 47.24 ) in + 'FR_DOUBLE_JESUS' => [2154.331, 3174.803], // = ( 760 x 1120 ) mm = ( 29.92 x 44.09 ) in + 'FR_GRAND_AIGLE' => [2125.984, 3004.724], // = ( 750 x 1060 ) mm = ( 29.53 x 41.73 ) in + 'FR_PETIT_AIGLE' => [1984.252, 2664.567], // = ( 700 x 940 ) mm = ( 27.56 x 37.01 ) in + 'FR_DOUBLE_RAISIN' => [1842.520, 2834.646], // = ( 650 x 1000 ) mm = ( 25.59 x 39.37 ) in + 'FR_JOURNAL' => [1842.520, 2664.567], // = ( 650 x 940 ) mm = ( 25.59 x 37.01 ) in + 'FR_COLOMBIER_AFFICHE' => [1785.827, 2551.181], // = ( 630 x 900 ) mm = ( 24.80 x 35.43 ) in + 'FR_DOUBLE_CAVALIER' => [1757.480, 2607.874], // = ( 620 x 920 ) mm = ( 24.41 x 36.22 ) in + 'FR_CLOCHE' => [1700.787, 2267.717], // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in + 'FR_SOLEIL' => [1700.787, 2267.717], // = ( 600 x 800 ) mm = ( 23.62 x 31.50 ) in + 'FR_DOUBLE_CARRE' => [1587.402, 2551.181], // = ( 560 x 900 ) mm = ( 22.05 x 35.43 ) in + 'FR_DOUBLE_COQUILLE' => [1587.402, 2494.488], // = ( 560 x 880 ) mm = ( 22.05 x 34.65 ) in + 'FR_JESUS' => [1587.402, 2154.331], // = ( 560 x 760 ) mm = ( 22.05 x 29.92 ) in + 'FR_RAISIN' => [1417.323, 1842.520], // = ( 500 x 650 ) mm = ( 19.69 x 25.59 ) in + 'FR_CAVALIER' => [1303.937, 1757.480], // = ( 460 x 620 ) mm = ( 18.11 x 24.41 ) in + 'FR_DOUBLE_COURONNE' => [1303.937, 2040.945], // = ( 460 x 720 ) mm = ( 18.11 x 28.35 ) in + 'FR_CARRE' => [1275.591, 1587.402], // = ( 450 x 560 ) mm = ( 17.72 x 22.05 ) in + 'FR_COQUILLE' => [1247.244, 1587.402], // = ( 440 x 560 ) mm = ( 17.32 x 22.05 ) in + 'FR_DOUBLE_TELLIERE' => [1247.244, 1927.559], // = ( 440 x 680 ) mm = ( 17.32 x 26.77 ) in + 'FR_DOUBLE_CLOCHE' => [1133.858, 1700.787], // = ( 400 x 600 ) mm = ( 15.75 x 23.62 ) in + 'FR_DOUBLE_POT' => [1133.858, 1757.480], // = ( 400 x 620 ) mm = ( 15.75 x 24.41 ) in + 'FR_ECU' => [1133.858, 1474.016], // = ( 400 x 520 ) mm = ( 15.75 x 20.47 ) in + 'FR_COURONNE' => [1020.472, 1303.937], // = ( 360 x 460 ) mm = ( 14.17 x 18.11 ) in + 'FR_TELLIERE' => [963.780, 1247.244], // = ( 340 x 440 ) mm = ( 13.39 x 17.32 ) in + 'FR_POT' => [878.740, 1133.858], // = ( 310 x 400 ) mm = ( 12.20 x 15.75 ) in // Colombian Sizes - 'CO_CARTA' => array( 612.283, 790.866), // = ( 216 x 279 ) mm = ( 8.50 x 10.98 ) in - 'CO_EXTRA_TABLOIDE' => array( 864.000, 1296.000), // = ( 304 x 457 ) mm = ( 12.00 x 18.00 ) in - 'CO_OFICIO' => array( 612.283, 935.433), // = ( 216 x 330 ) mm = ( 8.50 x 12.99 ) in - 'CO_PLIEGO' => array( 1984.252, 2834.646), // = ( 700 x 1000 ) mm = ( 27.56 x 39.37 ) in - 'CO_PLIEGO2' => array( 1417.323, 1984.252), // = ( 500 x 700 ) mm = ( 19.69 x 27.56 ) in - 'CO_PLIEGO4' => array( 992.126, 1417.323), // = ( 350 x 500 ) mm = ( 13.78 x 19.69 ) in - 'CO_PLIEGO8' => array( 708.661, 992.126), // = ( 250 x 350 ) mm = ( 9.84 x 13.78 ) in + 'CO_CARTA' => [612.283, 790.866], // = ( 216 x 279 ) mm = ( 8.50 x 10.98 ) in + 'CO_EXTRA_TABLOIDE' => [864.000, 1296.000], // = ( 304 x 457 ) mm = ( 12.00 x 18.00 ) in + 'CO_OFICIO' => [612.283, 935.433], // = ( 216 x 330 ) mm = ( 8.50 x 12.99 ) in + 'CO_PLIEGO' => [1984.252, 2834.646], // = ( 700 x 1000 ) mm = ( 27.56 x 39.37 ) in + 'CO_PLIEGO2' => [1417.323, 1984.252], // = ( 500 x 700 ) mm = ( 19.69 x 27.56 ) in + 'CO_PLIEGO4' => [992.126, 1417.323], // = ( 350 x 500 ) mm = ( 13.78 x 19.69 ) in + 'CO_PLIEGO8' => [708.661, 992.126], // = ( 250 x 350 ) mm = ( 9.84 x 13.78 ) in // Japanese Sizes - 'JP_AB_BAN' => array( 2494.488, 3075.591), // = ( 880 x 1085 ) mm = ( 34.65 x 42.72 ) in - 'JP_AIBAN' => array( 637.795, 977.953), // = ( 225 x 345 ) mm = ( 8.86 x 13.58 ) in - 'JP_A_KO_BAN' => array( 1723.465, 2454.803), // = ( 608 x 866 ) mm = ( 23.94 x 34.09 ) in - 'JP_B_KO_BAN' => array( 2137.323, 2967.874), // = ( 754 x 1047 ) mm = ( 29.69 x 41.22 ) in - 'JP_CHOUBO_BAN' => array( 2318.740, 3092.598), // = ( 818 x 1091 ) mm = ( 32.20 x 42.95 ) in - 'JP_CHUBAN' => array( 538.583, 722.835), // = ( 190 x 255 ) mm = ( 7.48 x 10.04 ) in - 'JP_CHU_TANZAKU' => array( 368.504, 1077.165), // = ( 130 x 380 ) mm = ( 5.12 x 14.96 ) in - 'JP_DAI OBAN' => array( 977.953, 1289.764), // = ( 345 x 455 ) mm = ( 13.58 x 17.91 ) in - 'JP_EBANKIRI' => array( 538.583, 1459.843), // = ( 190 x 515 ) mm = ( 7.48 x 20.28 ) in - 'JP_FUURUSU_KO_BAN' => array( 943.937, 1201.890), // = ( 333 x 424 ) mm = ( 13.11 x 16.69 ) in - 'JP_GAYOUSHI' => array( 1649.764, 2148.661), // = ( 582 x 758 ) mm = ( 22.91 x 29.84 ) in - 'JP_HASHIRE_E' => array( 368.504, 2069.291), // = ( 130 x 730 ) mm = ( 5.12 x 28.74 ) in - 'JP_HATORON_BAN' => array( 2551.181, 3401.575), // = ( 900 x 1200 ) mm = ( 35.43 x 47.24 ) in - 'JP_HOM_BAN' => array( 1842.520, 2211.024), // = ( 650 x 780 ) mm = ( 25.59 x 30.71 ) in - 'JP_HOSOBAN' => array( 411.024, 935.433), // = ( 145 x 330 ) mm = ( 5.71 x 12.99 ) in - 'JP_JIS_A_BAN' => array( 1771.654, 2494.488), // = ( 625 x 880 ) mm = ( 24.61 x 34.65 ) in - 'JP_JIS_B_BAN' => array( 2168.504, 3075.591), // = ( 765 x 1085 ) mm = ( 30.12 x 42.72 ) in - 'JP_KAKEMONO_E' => array( 651.969, 2154.331), // = ( 230 x 760 ) mm = ( 9.06 x 29.92 ) in - 'JP_KAKUBAN' => array( 504.567, 575.433), // = ( 178 x 203 ) mm = ( 7.01 x 7.99 ) in - 'JP_KAKU_SURIMONO' => array( 510.236, 609.449), // = ( 180 x 215 ) mm = ( 7.09 x 8.46 ) in - 'JP_KENTO_BAN' => array( 1374.803, 1768.819), // = ( 485 x 624 ) mm = ( 19.09 x 24.57 ) in - 'JP_KIKU_BAN' => array( 1802.835, 2661.732), // = ( 636 x 939 ) mm = ( 25.04 x 36.97 ) in - 'JP_KIKU_BAN4' => array( 643.465, 867.402), // = ( 227 x 306 ) mm = ( 8.94 x 12.05 ) in - 'JP_KIKU_BAN5' => array( 428.031, 643.465), // = ( 151 x 227 ) mm = ( 5.94 x 8.94 ) in - 'JP_KIKU_BAN5_OLD' => array( 430.866, 617.953), // = ( 152 x 218 ) mm = ( 5.98 x 8.58 ) in - 'JP_KIKU_BAN_A20_DORI' => array( 419.528, 473.386), // = ( 148 x 167 ) mm = ( 5.83 x 6.57 ) in - 'JP_KOBAN' => array( 481.890, 651.969), // = ( 170 x 230 ) mm = ( 6.69 x 9.06 ) in - 'JP_KO_BAN_B6' => array( 317.480, 493.228), // = ( 112 x 174 ) mm = ( 4.41 x 6.85 ) in - 'JP_KO_TANZAKU' => array( 215.433, 977.953), // = ( 76 x 345 ) mm = ( 2.99 x 13.58 ) in - 'JP_MOKUTANSHI' => array( 1332.283, 1760.315), // = ( 470 x 621 ) mm = ( 18.50 x 24.45 ) in - 'JP_NAGA_BAN' => array( 651.969, 1459.843), // = ( 230 x 515 ) mm = ( 9.06 x 20.28 ) in - 'JP_OBAN' => array( 720.000, 1077.165), // = ( 254 x 380 ) mm = ( 10.00 x 14.96 ) in - 'JP_OGATA_CHUBAN' => array( 615.118, 830.551), // = ( 217 x 293 ) mm = ( 8.54 x 11.54 ) in - 'JP_O_HOSOBAN' => array( 481.890, 1077.165), // = ( 170 x 380 ) mm = ( 6.69 x 14.96 ) in - 'JP_POSTCARD' => array( 283.465, 419.528), // = ( 100 x 148 ) mm = ( 3.94 x 5.83 ) in - 'JP_SANGO_BAN' => array( 238.110, 419.528), // = ( 84 x 148 ) mm = ( 3.31 x 5.83 ) in - 'JP_SANGO_BAN_A48_DORI' => array( 209.764, 396.850), // = ( 74 x 140 ) mm = ( 2.91 x 5.51 ) in - 'JP_SANGO_BAN_B20_DORI' => array( 515.906, 583.937), // = ( 182 x 206 ) mm = ( 7.17 x 8.11 ) in - 'JP_SANGO_BAN_B36_DORI' => array( 342.992, 484.724), // = ( 121 x 171 ) mm = ( 4.76 x 6.73 ) in - 'JP_SANGO_BAN_B40_DORI' => array( 238.110, 419.528), // = ( 84 x 148 ) mm = ( 3.31 x 5.83 ) in - 'JP_SANROKU_BAN_B48_DORI' => array( 257.953, 484.724), // = ( 91 x 171 ) mm = ( 3.58 x 6.73 ) in - 'JP_SANSAN_BAN' => array( 1975.748, 2834.646), // = ( 697 x 1000 ) mm = ( 27.44 x 39.37 ) in - 'JP_SANSHI_BAN' => array( 2060.787, 2834.646), // = ( 727 x 1000 ) mm = ( 28.62 x 39.37 ) in - 'JP_SHIKISHIBAN' => array( 581.102, 651.969), // = ( 205 x 230 ) mm = ( 8.07 x 9.06 ) in - 'JP_SHIMBUNYOUSHI' => array( 2304.567, 1547.717), // = ( 813 x 546 ) mm = ( 32.01 x 21.50 ) in - 'JP_SHINSHO_BAN_B40_A' => array( 300.472, 490.394), // = ( 106 x 173 ) mm = ( 4.17 x 6.81 ) in - 'JP_SHINSHO_BAN_B40_B' => array( 291.969, 515.906), // = ( 103 x 182 ) mm = ( 4.06 x 7.17 ) in - 'JP_SHIROKU_BAN' => array( 2233.701, 3092.598), // = ( 788 x 1091 ) mm = ( 31.02 x 42.95 ) in - 'JP_SHIROKU_BAN4' => array( 748.346, 1074.331), // = ( 264 x 379 ) mm = ( 10.39 x 14.92 ) in - 'JP_SHIROKU_BAN5' => array( 535.748, 742.677), // = ( 189 x 262 ) mm = ( 7.44 x 10.31 ) in - 'JP_SHIROKU_BAN5_OLD' => array( 541.417, 734.173), // = ( 191 x 259 ) mm = ( 7.52 x 10.20 ) in - 'JP_SHIROKU_BAN6' => array( 360.000, 532.913), // = ( 127 x 188 ) mm = ( 5.00 x 7.40 ) in - 'JP_SHO_TANZAKU' => array( 269.291, 722.835), // = ( 95 x 255 ) mm = ( 3.74 x 10.04 ) in - 'JP_SUITORISHI' => array( 1252.913, 1615.748), // = ( 442 x 570 ) mm = ( 17.40 x 22.44 ) in - 'JP_TANZAKU' => array( 360.000, 1218.898), // = ( 127 x 430 ) mm = ( 5.00 x 16.93 ) in - 'JP_TSUYA_GAMI' => array( 1440.000, 2160.000), // = ( 508 x 762 ) mm = ( 20.00 x 30.00 ) in - 'JP_UCHIWA' => array( 649.134, 720.000), // = ( 229 x 254 ) mm = ( 9.02 x 10.00 ) in - 'JP_WAIDO_BAN' => array( 595.276, 728.504), // = ( 210 x 257 ) mm = ( 8.27 x 10.12 ) in - 'JP_YATSUGIRI_BAN' => array( 269.291, 360.000), // = ( 95 x 127 ) mm = ( 3.74 x 5.00 ) in - ); + 'JP_AB_BAN' => [2494.488, 3075.591], // = ( 880 x 1085 ) mm = ( 34.65 x 42.72 ) in + 'JP_AIBAN' => [637.795, 977.953], // = ( 225 x 345 ) mm = ( 8.86 x 13.58 ) in + 'JP_A_KO_BAN' => [1723.465, 2454.803], // = ( 608 x 866 ) mm = ( 23.94 x 34.09 ) in + 'JP_B_KO_BAN' => [2137.323, 2967.874], // = ( 754 x 1047 ) mm = ( 29.69 x 41.22 ) in + 'JP_CHOUBO_BAN' => [2318.740, 3092.598], // = ( 818 x 1091 ) mm = ( 32.20 x 42.95 ) in + 'JP_CHUBAN' => [538.583, 722.835], // = ( 190 x 255 ) mm = ( 7.48 x 10.04 ) in + 'JP_CHU_TANZAKU' => [368.504, 1077.165], // = ( 130 x 380 ) mm = ( 5.12 x 14.96 ) in + 'JP_DAI OBAN' => [977.953, 1289.764], // = ( 345 x 455 ) mm = ( 13.58 x 17.91 ) in + 'JP_EBANKIRI' => [538.583, 1459.843], // = ( 190 x 515 ) mm = ( 7.48 x 20.28 ) in + 'JP_FUURUSU_KO_BAN' => [943.937, 1201.890], // = ( 333 x 424 ) mm = ( 13.11 x 16.69 ) in + 'JP_GAYOUSHI' => [1649.764, 2148.661], // = ( 582 x 758 ) mm = ( 22.91 x 29.84 ) in + 'JP_HASHIRE_E' => [368.504, 2069.291], // = ( 130 x 730 ) mm = ( 5.12 x 28.74 ) in + 'JP_HATORON_BAN' => [2551.181, 3401.575], // = ( 900 x 1200 ) mm = ( 35.43 x 47.24 ) in + 'JP_HOM_BAN' => [1842.520, 2211.024], // = ( 650 x 780 ) mm = ( 25.59 x 30.71 ) in + 'JP_HOSOBAN' => [411.024, 935.433], // = ( 145 x 330 ) mm = ( 5.71 x 12.99 ) in + 'JP_JIS_A_BAN' => [1771.654, 2494.488], // = ( 625 x 880 ) mm = ( 24.61 x 34.65 ) in + 'JP_JIS_B_BAN' => [2168.504, 3075.591], // = ( 765 x 1085 ) mm = ( 30.12 x 42.72 ) in + 'JP_KAKEMONO_E' => [651.969, 2154.331], // = ( 230 x 760 ) mm = ( 9.06 x 29.92 ) in + 'JP_KAKUBAN' => [504.567, 575.433], // = ( 178 x 203 ) mm = ( 7.01 x 7.99 ) in + 'JP_KAKU_SURIMONO' => [510.236, 609.449], // = ( 180 x 215 ) mm = ( 7.09 x 8.46 ) in + 'JP_KENTO_BAN' => [1374.803, 1768.819], // = ( 485 x 624 ) mm = ( 19.09 x 24.57 ) in + 'JP_KIKU_BAN' => [1802.835, 2661.732], // = ( 636 x 939 ) mm = ( 25.04 x 36.97 ) in + 'JP_KIKU_BAN4' => [643.465, 867.402], // = ( 227 x 306 ) mm = ( 8.94 x 12.05 ) in + 'JP_KIKU_BAN5' => [428.031, 643.465], // = ( 151 x 227 ) mm = ( 5.94 x 8.94 ) in + 'JP_KIKU_BAN5_OLD' => [430.866, 617.953], // = ( 152 x 218 ) mm = ( 5.98 x 8.58 ) in + 'JP_KIKU_BAN_A20_DORI' => [419.528, 473.386], // = ( 148 x 167 ) mm = ( 5.83 x 6.57 ) in + 'JP_KOBAN' => [481.890, 651.969], // = ( 170 x 230 ) mm = ( 6.69 x 9.06 ) in + 'JP_KO_BAN_B6' => [317.480, 493.228], // = ( 112 x 174 ) mm = ( 4.41 x 6.85 ) in + 'JP_KO_TANZAKU' => [215.433, 977.953], // = ( 76 x 345 ) mm = ( 2.99 x 13.58 ) in + 'JP_MOKUTANSHI' => [1332.283, 1760.315], // = ( 470 x 621 ) mm = ( 18.50 x 24.45 ) in + 'JP_NAGA_BAN' => [651.969, 1459.843], // = ( 230 x 515 ) mm = ( 9.06 x 20.28 ) in + 'JP_OBAN' => [720.000, 1077.165], // = ( 254 x 380 ) mm = ( 10.00 x 14.96 ) in + 'JP_OGATA_CHUBAN' => [615.118, 830.551], // = ( 217 x 293 ) mm = ( 8.54 x 11.54 ) in + 'JP_O_HOSOBAN' => [481.890, 1077.165], // = ( 170 x 380 ) mm = ( 6.69 x 14.96 ) in + 'JP_POSTCARD' => [283.465, 419.528], // = ( 100 x 148 ) mm = ( 3.94 x 5.83 ) in + 'JP_SANGO_BAN' => [238.110, 419.528], // = ( 84 x 148 ) mm = ( 3.31 x 5.83 ) in + 'JP_SANGO_BAN_A48_DORI' => [209.764, 396.850], // = ( 74 x 140 ) mm = ( 2.91 x 5.51 ) in + 'JP_SANGO_BAN_B20_DORI' => [515.906, 583.937], // = ( 182 x 206 ) mm = ( 7.17 x 8.11 ) in + 'JP_SANGO_BAN_B36_DORI' => [342.992, 484.724], // = ( 121 x 171 ) mm = ( 4.76 x 6.73 ) in + 'JP_SANGO_BAN_B40_DORI' => [238.110, 419.528], // = ( 84 x 148 ) mm = ( 3.31 x 5.83 ) in + 'JP_SANROKU_BAN_B48_DORI' => [257.953, 484.724], // = ( 91 x 171 ) mm = ( 3.58 x 6.73 ) in + 'JP_SANSAN_BAN' => [1975.748, 2834.646], // = ( 697 x 1000 ) mm = ( 27.44 x 39.37 ) in + 'JP_SANSHI_BAN' => [2060.787, 2834.646], // = ( 727 x 1000 ) mm = ( 28.62 x 39.37 ) in + 'JP_SHIKISHIBAN' => [581.102, 651.969], // = ( 205 x 230 ) mm = ( 8.07 x 9.06 ) in + 'JP_SHIMBUNYOUSHI' => [2304.567, 1547.717], // = ( 813 x 546 ) mm = ( 32.01 x 21.50 ) in + 'JP_SHINSHO_BAN_B40_A' => [300.472, 490.394], // = ( 106 x 173 ) mm = ( 4.17 x 6.81 ) in + 'JP_SHINSHO_BAN_B40_B' => [291.969, 515.906], // = ( 103 x 182 ) mm = ( 4.06 x 7.17 ) in + 'JP_SHIROKU_BAN' => [2233.701, 3092.598], // = ( 788 x 1091 ) mm = ( 31.02 x 42.95 ) in + 'JP_SHIROKU_BAN4' => [748.346, 1074.331], // = ( 264 x 379 ) mm = ( 10.39 x 14.92 ) in + 'JP_SHIROKU_BAN5' => [535.748, 742.677], // = ( 189 x 262 ) mm = ( 7.44 x 10.31 ) in + 'JP_SHIROKU_BAN5_OLD' => [541.417, 734.173], // = ( 191 x 259 ) mm = ( 7.52 x 10.20 ) in + 'JP_SHIROKU_BAN6' => [360.000, 532.913], // = ( 127 x 188 ) mm = ( 5.00 x 7.40 ) in + 'JP_SHO_TANZAKU' => [269.291, 722.835], // = ( 95 x 255 ) mm = ( 3.74 x 10.04 ) in + 'JP_SUITORISHI' => [1252.913, 1615.748], // = ( 442 x 570 ) mm = ( 17.40 x 22.44 ) in + 'JP_TANZAKU' => [360.000, 1218.898], // = ( 127 x 430 ) mm = ( 5.00 x 16.93 ) in + 'JP_TSUYA_GAMI' => [1440.000, 2160.000], // = ( 508 x 762 ) mm = ( 20.00 x 30.00 ) in + 'JP_UCHIWA' => [649.134, 720.000], // = ( 229 x 254 ) mm = ( 9.02 x 10.00 ) in + 'JP_WAIDO_BAN' => [595.276, 728.504], // = ( 210 x 257 ) mm = ( 8.27 x 10.12 ) in + 'JP_YATSUGIRI_BAN' => [269.291, 360.000], // = ( 95 x 127 ) mm = ( 3.74 x 5.00 ) in + ]; /** * Get page dimensions. @@ -483,16 +483,21 @@ abstract class Format * @param string $unit Unit name (default points). * @param int $dec Number of decimals to return. * - * @return array Page width, height and orientation in specified unit. + * @return array{0:float, 1:float, 2:string} Page width, height and orientation in specified unit. */ - public function getPageFormatSize($format, $orientation = '', $unit = '', $dec = 6) - { - if (!isset(self::$format[$format])) { + public function getPageFormatSize( + string $format, + string $orientation = '', + string $unit = '', + int $dec = 6 + ): array { + if (! isset(self::FORMAT[$format])) { throw new PageException('unknown page format: ' . $format); } + return $this->getPageOrientedSize( - $this->convertPoints(self::$format[$format][0], $unit, $dec), - $this->convertPoints(self::$format[$format][1], $unit, $dec), + $this->convertPoints(self::FORMAT[$format][0], $unit, $dec), + $this->convertPoints(self::FORMAT[$format][1], $unit, $dec), $orientation ); } @@ -500,54 +505,59 @@ public function getPageFormatSize($format, $orientation = '', $unit = '', $dec = /** * Returns the page dimensions oriented as specified. * - * @param float $width Page width. - * @param float $height Page height. + * @param float $width Page width. + * @param float $height Page height. * @param string $orientation Page orientation ('P' = portrait; 'L' = landscape, '' = default). * - * @return array Page width and height in points. + * @return array{0:float, 1:float, 2:string} Page width, height in points and orientation. */ - public function getPageOrientedSize($width, $height, $orientation = '') - { + public function getPageOrientedSize( + float $width, + float $height, + string $orientation = '' + ): array { if ($orientation == 'P') { - return array(min($width, $height), max($width, $height), 'P'); + return [min($width, $height), max($width, $height), 'P']; } + if ($orientation == 'L') { - return array(max($width, $height), min($width, $height), 'L'); + return [max($width, $height), min($width, $height), 'L']; } + $orientation = $this->getPageOrientation($width, $height); - return array($width, $height, $orientation); + return [$width, $height, $orientation]; } /** * Returns the page orientation. * - * @param float $width Page width. - * @param float $height Page height. + * @param float $width Page width. + * @param float $height Page height. * * @return string page orientation 'P' or 'L'. */ - public function getPageOrientation($width, $height) + public function getPageOrientation(float $width, float $height): string { if ($width <= $height) { return 'P'; } + return 'L'; } /** * Get the unit ratio for the specified unit of measure. * - * @param string $unit Name of the unit of measure. - * - * @return float + * @param string $unit Name of the unit of measure. */ - public function getUnitRatio($unit) + public function getUnitRatio(string $unit): float { $unit = strtolower($unit); - if (!isset(self::$unitratio[$unit])) { + if (! isset(self::UNITRATIO[$unit])) { throw new PageException('unknown unit: ' . $unit); } - return self::$unitratio[$unit]; + + return self::UNITRATIO[$unit]; } /** @@ -556,10 +566,8 @@ public function getUnitRatio($unit) * @param float $points Value to convert. * @param string $unit Name of the unit to convert to. * @param int $dec Number of decimals to return. - * - * @return float */ - public function convertPoints($points, $unit, $dec = 6) + public function convertPoints(float $points, string $unit, int $dec = 6): float { return round(($points / $this->getUnitRatio($unit)), $dec); } diff --git a/src/Mode.php b/src/Mode.php index 4b709ca..f424d35 100644 --- a/src/Mode.php +++ b/src/Mode.php @@ -3,13 +3,13 @@ /** * Mode.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ @@ -19,48 +19,48 @@ /** * Com\Tecnick\Pdf\Page\Mode * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ abstract class Mode extends \Com\Tecnick\Pdf\Page\Format { /** * Map layouts with their canonical names * - * @var array + * @var array */ - protected static $layout = array( - 'singlepage' => 'SinglePage', // Display one page at a time - 'default' => 'SinglePage', - 'single' => 'SinglePage', - 'onecolumn' => 'OneColumn', // Display the pages in one column - 'continuous' => 'OneColumn', - 'twocolumnleft' => 'TwoColumnLeft', // Display the pages in two columns, with odd-numbered pages on the left - 'two' => 'TwoColumnLeft', + protected const LAYOUT = [ + 'singlepage' => 'SinglePage', // Display one page at a time + 'default' => 'SinglePage', + 'single' => 'SinglePage', + 'onecolumn' => 'OneColumn', // Display the pages in one column + 'continuous' => 'OneColumn', + 'twocolumnleft' => 'TwoColumnLeft', // Display the pages in two columns, with odd-numbered pages on the left + 'two' => 'TwoColumnLeft', 'twocolumnright' => 'TwoColumnRight', // Display the pages in two columns, with odd-numbered pages on the right - 'twopageleft' => 'TwoPageLeft', // Display the pages two at a time, with odd-numbered pages on the left - 'twopageright' => 'TwoPageRight' // Display the pages two at a time, with odd-numbered pages on the right - ); + 'twopageleft' => 'TwoPageLeft', // Display the pages two at a time, with odd-numbered pages on the left + 'twopageright' => 'TwoPageRight', // Display the pages two at a time, with odd-numbered pages on the right + ]; /** * Map display modes with their canonical names * - * @var array + * @var array */ - protected static $display = array( - 'usenone' => 'UseNone', // Neither document outline nor thumbnail images visible - 'useoutlines' => 'UseOutlines', // Document outline visible - 'usethumbs' => 'UseThumbs', // Thumbnail images visible - 'fullscreen' => 'FullScreen', // Full-screen mode, with no menu bar or window controls - 'useoc' => 'UseOC', // (PDF 1.5) Optional content group panel visible + protected const DISPLAY = [ + 'usenone' => 'UseNone', // Neither document outline nor thumbnail images visible + 'useoutlines' => 'UseOutlines', // Document outline visible + 'usethumbs' => 'UseThumbs', // Thumbnail images visible + 'fullscreen' => 'FullScreen', // Full-screen mode, with no menu bar or window controls + 'useoc' => 'UseOC', // (PDF 1.5) Optional content group panel visible 'useattachments' => 'UseAttachments', // (PDF 1.6) Attachments panel visible - '' => 'UseAttachments' // (PDF 1.6) Attachments panel visible - ); + '' => 'UseAttachments', // (PDF 1.6) Attachments panel visible + ]; /** * Get the canonical page layout name. @@ -69,13 +69,10 @@ abstract class Mode extends \Com\Tecnick\Pdf\Page\Format * * @return string Canonical page layout name. */ - public function getLayout($name = '') + public function getLayout(string $name = ''): string { $name = strtolower($name); - if (isset(self::$layout[$name])) { - return self::$layout[$name]; - } - return 'SinglePage'; + return self::LAYOUT[$name] ?? 'SinglePage'; } /** @@ -85,12 +82,9 @@ public function getLayout($name = '') * * @return string Canonical page display mode. */ - public function getDisplay($mode = '') + public function getDisplay(string $mode = ''): string { $mode = strtolower($mode); - if (isset(self::$display[$mode])) { - return self::$display[$mode]; - } - return 'UseNone'; + return self::DISPLAY[$mode] ?? 'UseNone'; } } diff --git a/src/Page.php b/src/Page.php index c2e47f1..f844c24 100644 --- a/src/Page.php +++ b/src/Page.php @@ -3,13 +3,13 @@ /** * Page.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ @@ -23,13 +23,13 @@ /** * Com\Tecnick\Pdf\Page\Page * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ @@ -39,26 +39,26 @@ class Page extends \Com\Tecnick\Pdf\Page\Region * Initialize page data. * * @param string $unit Unit of measure ('pt', 'mm', 'cm', 'in'). - * @param Color $col Color object. - * @param Encrypt $enc Encrypt object. + * @param Color $color Color object. + * @param Encrypt $encrypt Encrypt object. * @param bool $pdfa True if we are in PDF/A mode. * @param bool $compress Set to false to disable stream compression. * @param bool $sigapp True if the signature approval is enabled (for incremental updates). */ public function __construct( - $unit, - Color $col, - Encrypt $enc, - $pdfa = false, - $compress = true, - $sigapp = false + string $unit, + Color $color, + Encrypt $encrypt, + bool $pdfa = false, + bool $compress = true, + bool $sigapp = false ) { $this->kunit = $this->getUnitRatio($unit); - $this->col = $col; - $this->enc = $enc; - $this->pdfa = (bool) $pdfa; - $this->compress = (bool) $compress; - $this->sigapp = (bool) $sigapp; + $this->col = $color; + $this->enc = $encrypt; + $this->pdfa = $pdfa; + $this->compress = $compress; + $this->sigapp = $sigapp; } /** @@ -66,7 +66,7 @@ public function __construct( * * @return float Unit Ratio. */ - public function getKUnit() + public function getKUnit(): float { return $this->kunit; } @@ -76,9 +76,9 @@ public function getKUnit() * * @param bool $sigapp True if the signature approval is enabled (for incremental updates). */ - public function enableSignatureApproval($sigapp) + public function enableSignatureApproval(bool $sigapp): static { - $this->sigapp = (bool) $sigapp; + $this->sigapp = $sigapp; return $this; } @@ -87,13 +87,81 @@ public function enableSignatureApproval($sigapp) * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array Removed page. + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Removed page. */ - public function delete($pid = -1) + public function delete(int $pid = -1): array { $pid = $this->sanitizePageID($pid); $page = $this->page[$pid]; - $this->group[$this->page[$pid]['group']] -= 1; + --$this->group[$this->page[$pid]['group']]; unset($this->page[$pid]); $this->page = array_values($this->page); // reindex array --$this->pmaxid; @@ -103,9 +171,77 @@ public function delete($pid = -1) /** * Remove and return last page. * - * @return array Removed page. + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Removed page. */ - public function pop() + public function pop(): array { return $this->delete($this->pmaxid); } @@ -116,27 +252,96 @@ public function pop() * @param int $from Index of the page to move. * @param int $new Destination index. */ - public function move($from, $new) + public function move(int $from, int $new): void { if (($from <= $new) || ($from > $this->pmaxid)) { throw new PageException('The new position must be lower than the starting position'); } + $this->page = array_values( - array_merge( - array_slice($this->page, 0, $new), - array($this->page[$from]), - array_slice($this->page, $new, ($from - $new)), - array_slice($this->page, ($from + 1)) - ) + [ + ...array_slice($this->page, 0, $new), + $this->page[$from], + ...array_slice($this->page, $new, ($from - $new)), + ...array_slice($this->page, ($from + 1)), + ] ); } /** * Returns the array (stack) containing all pages data. * - * return array Pages. + * @return array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * }> Pages. */ - public function getPages() + public function getPages(): array { return $this->page; } @@ -147,10 +352,10 @@ public function getPages() * @param int $oid Annotation object IDs. * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function addAnnotRef($oid, $pid = -1) + public function addAnnotRef(int $oid, int $pid = -1): void { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['annotrefs'][] = (int) $oid; + $this->page[$pid]['annotrefs'][] = $oid; } /** @@ -159,23 +364,26 @@ public function addAnnotRef($oid, $pid = -1) * @param string $content Page content. * @param int $pid Page index. Omit or set it to -1 for the current page ID. */ - public function addContent($content, $pid = -1) + public function addContent(string $content, int $pid = -1): void { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['content'][] = (string) $content; + $this->page[$pid]['content'][] = $content; } /** * Remove and return last page content. * * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return string */ - public function popContent($pid = -1) + public function popContent(int $pid = -1): string { $pid = $this->sanitizePageID($pid); - return array_pop($this->page[$pid]['content']); + $page = array_pop($this->page[$pid]['content']); + if ($page === null) { + throw new PageException('Page content is empty'); + } + + return $page; } /** @@ -183,7 +391,7 @@ public function popContent($pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function addContentMark($pid = -1) + public function addContentMark(int $pid = -1): void { $pid = $this->sanitizePageID($pid); $this->page[$pid]['content_mark'][] = count($this->page[$pid]['content']); @@ -194,7 +402,7 @@ public function addContentMark($pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function popContentToLastMark($pid = -1) + public function popContentToLastMark(int $pid = -1): void { $pid = $this->sanitizePageID($pid); $mark = array_pop($this->page[$pid]['content_mark']); @@ -208,22 +416,20 @@ public function popContentToLastMark($pid = -1) * * @return string PDF command. */ - public function getPdfPages(&$pon) + public function getPdfPages(int &$pon): string { $out = $this->getPageRootObj($pon); foreach ($this->page as $num => $page) { - if (!isset($page['num'])) { + if (! isset($page['num'])) { if ($num > 0) { - if ($page['group'] == $this->page[($num - 1)]['group']) { - $page['num'] = (1 + $this->page[($num - 1)]['num']); - } else { - // new page group - $page['num'] = 1; - } + $page['num'] = ( + $page['group'] == $this->page[($num - 1)]['group'] + ) ? (1 + $this->page[($num - 1)]['num']) : 1; } else { $page['num'] = (1 + $num); } } + $this->page[$num]['num'] = $page['num']; $content = $this->replacePageTemplates($page); @@ -234,12 +440,14 @@ public function getPdfPages(&$pon) . '<<' . "\n" . '/Type /Page' . "\n" . '/Parent ' . $this->rootoid . ' 0 R' . "\n"; - if (!$this->pdfa) { + if (! $this->pdfa) { $out .= '/Group << /Type /Group /S /Transparency /CS /DeviceRGB >>' . "\n"; } - if (!$this->sigapp) { + + if (! $this->sigapp) { $out .= '/LastModified ' . $this->enc->getFormattedDate($page['time'], $pon) . "\n"; } + $out .= '/Resources ' . $this->rdoid . ' 0 R' . "\n" . $this->getBox($page['box']) . $this->getBoxColorInfo($page['box']) @@ -251,15 +459,16 @@ public function getPdfPages(&$pon) . '>>' . "\n" . 'endobj' . "\n"; } + return $out; } /** * Returns the reserved Object ID for the Resource dictionary. * - * return int Resource dictionary Object ID. + * @return int Resource dictionary Object ID. */ - public function getResourceDictObjID() + public function getResourceDictObjID(): int { return $this->rdoid; } @@ -267,9 +476,9 @@ public function getResourceDictObjID() /** * Returns the root object ID. * - * return int Root Object ID. + * @return int Root Object ID. */ - public function getRootObjID() + public function getRootObjID(): int { return $this->rootoid; } @@ -277,20 +486,88 @@ public function getRootObjID() /** * Returns the PDF command to output the page content. * - * @param array $page Page data. + * @param array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } $page Page data. * * @return string PDF command. */ - protected function getPageTransition($page) + protected function getPageTransition(array $page): string { if (empty($page['transition'])) { return ''; } - $entries = array('S', 'D', 'Dm', 'M', 'Di', 'SS', 'B'); + + $entries = ['B', 'D', 'Di', 'Dm', 'M', 'S', 'SS']; $out = ''; - if (isset($page['transition']['Dur'])) { - $out .= '/Dur ' . sprintf('%F', $page['transition']['Dur']) . "\n"; - } + $out .= '/Dur ' . sprintf('%F', $page['transition']['Dur']) . "\n"; + $out .= '/Trans <<' . "\n" . '/Type /Trans' . "\n"; foreach ($page['transition'] as $key => $val) { @@ -298,31 +575,101 @@ protected function getPageTransition($page) if (is_float($val)) { $val = sprintf('%F', $val); } + $out .= '/' . $key . ' /' . $val . "\n"; } } - $out .= '>>' . "\n"; - return $out; + + return $out . ('>>' . "\n"); } /** * Get references to page annotations. * - * @param array $page Page data. + * @param array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } $page Page data. * * @return string PDF command. */ - protected function getAnnotationRef($page) + protected function getAnnotationRef(array $page): string { if (empty($page['annotrefs'])) { return ''; } + $out = '/Annots [ '; foreach ($page['annotrefs'] as $val) { - $out .= intval($val) . ' 0 R '; + $out .= (int) $val . ' 0 R '; } - $out .= ']' . "\n"; - return $out; + + return $out . (']' . "\n"); } /** @@ -333,22 +680,25 @@ protected function getAnnotationRef($page) * * @return string PDF command. */ - protected function getPageContentObj(&$pon, $content = '') + protected function getPageContentObj(int &$pon, string $content = ''): string { $out = ++$pon . ' 0 obj' . "\n" . '<<'; if ($this->compress) { $out .= ' /Filter /FlateDecode'; - $content = gzcompress($content); + $cmpr = gzcompress($content); + if ($cmpr !== false) { + $content = $cmpr; + } } + $stream = $this->enc->encryptString($content, $pon); - $out .= ' /Length ' . strlen($stream) + return $out . (' /Length ' . strlen($stream) . ' >>' . "\n" . 'stream' . "\n" . $stream . "\n" . 'endstream' . "\n" - . 'endobj' . "\n"; - return $out; + . 'endobj' . "\n"); } /** @@ -358,7 +708,7 @@ protected function getPageContentObj(&$pon, $content = '') * * @return string PDF command. */ - protected function getPageRootObj(&$pon) + protected function getPageRootObj(int &$pon): string { $this->rdoid = ++$pon; // reserve object ID for the resource dictionary $this->rootoid = ++$pon; @@ -369,23 +719,91 @@ protected function getPageRootObj(&$pon) $this->page[$pid]['n'] = ++$pon; $out .= $this->page[$pid]['n'] . ' 0 R '; } - $out .= '] /Count ' . $numpages . ' >>' . "\n" - . 'endobj' . "\n"; - return $out; + + return $out . ('] /Count ' . $numpages . ' >>' . "\n" + . 'endobj' . "\n"); } /** * Replace page templates and numbers. * - * @param array $data Page data. + * @param array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } $data Page data. */ - protected function replacePageTemplates(array $data) + protected function replacePageTemplates(array $data): string { return implode( "\n", str_replace( - array(self::PAGE_TOT, self::PAGE_NUM), - array($this->group[$data['group']], $data['num']), + [self::PAGE_TOT, self::PAGE_NUM], + [$this->group[$data['group']], $data['num']], $data['content'] ) ); diff --git a/src/Region.php b/src/Region.php index 023f5f3..c82cbdc 100644 --- a/src/Region.php +++ b/src/Region.php @@ -3,32 +3,31 @@ /** * Region.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Com\Tecnick\Pdf\Page; -use Com\Tecnick\Color\Pdf as Color; use Com\Tecnick\Pdf\Page\Exception as PageException; /** * Com\Tecnick\Pdf\Page\Region * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * A page region defines the writable area of the page. */ @@ -37,21 +36,98 @@ abstract class Region extends \Com\Tecnick\Pdf\Page\Settings /** * Add a new page. * - * @param array $data Page data: - * time : UTC page modification time in seconds; - * group : page group number; - * num : if set overwrites the page number; - * content : string containing the raw page content; + * @param array{ + * 'annotrefs'?: array, + * 'autobreak'?: bool, + * 'box'?: array, + * }, + * }>, + * 'columns'?: int, + * 'content'?: array, + * 'content_mark'?: array, + * 'ContentHeight'?: float, + * 'ContentWidth'?: float, + * 'FooterHeight'?: float, + * 'HeaderHeight'?: float, + * 'currentRegion'?: int, + * 'format'?: string, + * 'group'?: int, + * 'height'?: float, + * 'margin'?: array{ + * 'CB'?: float, + * 'CT'?: float, + * 'FT'?: float, + * 'HB'?: float, + * 'PB'?: float, + * 'PL'?: float, + * 'PR'?: float, + * 'PT'?: float, + * }, + * 'n'?: int, + * 'num'?: int, + * 'orientation'?: string, + * 'pagenum'?: int, + * 'pheight'?: float, + * 'pid'?: int, + * 'pwidth'?: float, + * 'region'?: array, + * 'rotation'?: int, + * 'time'?: int, + * 'transition'?: array{ + * 'B'?: bool, + * 'D'?: int, + * 'Di'?: string|int, + * 'Dm'?: string, + * 'Dur'?: float, + * 'M'?: string, + * 'S'?: string, + * 'SS'?: float, + * }, + * 'width'?: float, + * 'zoom'?: float, + * } $data Page data: * annotrefs : array containing the annotation object references; + * autobreak : true to automatically add a page when the content reaches the breaking point. + * box : array containing page box boundaries and settings (@see setBox); + * columns : number of equal vertical columns, if set it will automatically populate the region array + * content : string containing the raw page content; * format : page format name, or alternatively you can set width and height as below; - * width : page width; + * group : page group number; * height : page height; + * margin : page margins: + * num : if set overwrites the page number; * orientation : page orientation ('P' or 'L'); + * region : array containing the ordered list of rectangular areas where it is allowed to write, + * each region is defined by: + * RX : horizontal coordinate of top-left corner + * RY : vertical coordinate of top-left corner + * RW : region width + * RH : region height * rotation : the number of degrees by which the page shall be rotated clockwise when displayed or printed; - * box : array containing page box boundaries and settings (@see setBox); + * time : UTC page modification time in seconds; * transition : array containing page transition data (@see getPageTransition); + * width : page width; * zoom : preferred zoom (magnification) factor; - * margin : page margins: * PL : page left margin measured from the left page edge * PR : page right margin measured from the right page edge * PT : page top or header top measured distance from the top page edge @@ -60,22 +136,83 @@ abstract class Region extends \Com\Tecnick\Pdf\Page\Settings * CB : content bottom (page breaking point) measured from the top page edge * FT : footer top measured from the bottom page edge * PB : page bottom (footer bottom) measured from the bottom page edge - * columns : number of equal vertical columns, if set it will automatically populate the region array - * region : array containing the ordered list of rectangular areas where it is allowed to write, - * each region is defined by: - * RX : horizontal coordinate of top-left corner - * RY : vertical coordinate of top-left corner - * RW : region width - * RH : region height - * autobreak : true to automatically add a page when the content reaches the breaking point. * - * NOTE: if $data is empty, then the last page format will be cloned. - * - * @return array Page data with additional Page ID property 'pid'. + * NOTE: if $data is null, then the last page format will be cloned. + * + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{ + * 'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Page data with additional Page ID property 'pid'. */ - public function add(array $data = array()) + public function add(array $data = []): array { - if (empty($data) && ($this->pmaxid >= 0)) { + if (($data === []) && ($this->pmaxid >= 0)) { // clone last page data $data = $this->page[$this->pmaxid]; unset($data['time'], $data['content'], $data['annotrefs'], $data['pagenum']); @@ -89,20 +226,22 @@ public function add(array $data = array()) $this->sanitizeMargins($data); $this->sanitizeRegions($data); } + $this->sanitizeTime($data); $this->sanitizeContent($data); $this->sanitizeAnnotRefs($data); $this->sanitizePageNumber($data); - $data['content_mark'] = array(0); + $data['content_mark'] = [0]; $data['currentRegion'] = 0; $data['pid'] = ++$this->pmaxid; $this->pid = $data['pid']; $this->page[$this->pid] = $data; if (isset($this->group[$data['group']])) { - $this->group[$data['group']] += 1; + ++$this->group[(int) $data['group']]; } else { - $this->group[$data['group']] = 1; + $this->group[(int) $data['group']] = 1; } + return $this->page[$this->pid]; } @@ -110,8 +249,78 @@ public function add(array $data = array()) * Set the current page number (move to the specified page). * * @param int $pid page index. Omit or set it to -1 for the current page ID. + * + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Page data. */ - public function setCurrentPage($pid = -1) + public function setCurrentPage(int $pid = -1): array { $pid = $this->sanitizePageID($pid); $this->pid = $pid; @@ -123,9 +332,77 @@ public function setCurrentPage($pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * return array + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Page data. */ - public function getPage($pid = -1) + public function getPage(int $pid = -1): array { $pid = $this->sanitizePageID($pid); return $this->page[$pid]; @@ -138,14 +415,16 @@ public function getPage($pid = -1) * * @return int Page ID. */ - protected function sanitizePageID($pid = -1) + protected function sanitizePageID(int $pid = -1): int { if ($pid < 0) { $pid = $this->pid; } - if (!isset($this->page[$pid])) { + + if (! isset($this->page[$pid])) { throw new PageException('The page with index ' . $pid . ' do not exist.'); } + return $pid; } @@ -155,12 +434,23 @@ protected function sanitizePageID($pid = -1) * @param int $idr ID of the region. * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array Selected region data. + * @return array{ + * 'RB': float, + * 'RH': float, + * 'RL': float, + * 'RR': float, + * 'RT': float, + * 'RW': float, + * 'RX': float, + * 'RY': float, + * 'x' : float, + * 'y' : float, + * } Selected region data. */ - public function selectRegion($idr, $pid = -1) + public function selectRegion(int $idr, int $pid = -1): array { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['currentRegion'] = min(max(0, intval($idr)), $this->page[$pid]['columns']); + $this->page[$pid]['currentRegion'] = min(max(0, $idr), $this->page[$pid]['columns']); return $this->getRegion(); } @@ -169,9 +459,20 @@ public function selectRegion($idr, $pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array Region. + * @return array{ + * 'RB': float, + * 'RH': float, + * 'RL': float, + * 'RR': float, + * 'RT': float, + * 'RW': float, + * 'RX': float, + * 'RY': float, + * 'x' : float, + * 'y' : float, + * } Region. */ - public function getRegion($pid = -1) + public function getRegion(int $pid = -1): array { $pid = $this->sanitizePageID($pid); return $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]; @@ -183,18 +484,88 @@ public function getRegion($pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array Page data. + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Page data. */ - public function getNextPage($pid = -1) + public function getNextPage(int $pid = -1): array { $pid = $this->sanitizePageID($pid); if ($pid < $this->pmaxid) { $this->pid = ++$pid; return $this->page[$this->pid]; } - if (!$this->isAutoPageBreakEnabled()) { + + if (! $this->isAutoPageBreakEnabled()) { return $this->setCurrentPage($pid); } + return $this->add(); } @@ -205,9 +576,77 @@ public function getNextPage($pid = -1) * * @param int $pid page index. Omit or set it to -1 for the current page ID. * - * @return array Current page data. + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Current page data. */ - public function getNextRegion($pid = -1) + public function getNextRegion(int $pid = -1): array { $pid = $this->sanitizePageID($pid); $nextid = ($this->page[$pid]['currentRegion'] + 1); @@ -215,23 +654,96 @@ public function getNextRegion($pid = -1) $this->page[$pid]['currentRegion'] = $nextid; return $this->page[$pid]; } + return $this->getNextPage($pid); } /** * Move to the next page region if required. * - * @param float $height Height of the block to add. - * @param float $ypos Starting Y position or NULL for current position. - * @param int $pid Page index. Omit or set it to -1 for the current page ID. - * - * @return array Page data. + * @param float $height Height of the block to add. + * @param ?float $ypos Starting Y position or NULL for current position. + * @param int $pid Page index. Omit or set it to -1 for the current page ID. + * + * @return array{ + * 'annotrefs': array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * } Page data. */ - public function checkRegionBreak($height = 0, $ypos = null, $pid = -1) - { + public function checkRegionBreak( + float $height = 0.0, + ?float $ypos = null, + int $pid = -1, + ): array { if ($this->isYOutRegion($ypos, $height, $pid)) { return $this->getNextRegion($pid); } + return $this->getPage($pid); } @@ -242,7 +754,7 @@ public function checkRegionBreak($height = 0, $ypos = null, $pid = -1) * * @return bool True if the auto page break is enabled, false otherwise. */ - public function isAutoPageBreakEnabled($pid = -1) + public function isAutoPageBreakEnabled(int $pid = -1): bool { $pid = $this->sanitizePageID($pid); return $this->page[$pid]['autobreak']; @@ -252,12 +764,12 @@ public function isAutoPageBreakEnabled($pid = -1) * Enable or disable automatic page break. * * @param bool $isenabled Set this to true to enable automatic page break. - * @param int $pid page index. Omit or set it to -1 for the current page ID. + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function enableAutoPageBreak($isenabled = true, $pid = -1) + public function enableAutoPageBreak(bool $isenabled = true, int $pid = -1): void { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['autobreak'] = (bool) $isenabled; + $this->page[$pid]['autobreak'] = $isenabled; } /** @@ -266,11 +778,9 @@ public function enableAutoPageBreak($isenabled = true, $pid = -1) * @param float $pos Position. * @param string $min ID of the min region value to check. * @param string $max ID of the max region value to check. - * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return boolean + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - private function isOutRegion($pos, $min, $max, $pid = -1) + private function isOutRegion(float $pos, string $min, string $max, int $pid = -1): bool { $region = $this->getRegion($pid); return (($pos < ($region[$min] - self::EPS)) || ($pos > ($region[$max] + self::EPS))); @@ -279,45 +789,47 @@ private function isOutRegion($pos, $min, $max, $pid = -1) /** * Check if the specified vertical position is outside the region. * - * @param float $posy Y position or NULL for current position. - * @param float $height Additional height to add. - * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return boolean + * @param ?float $posy Y position or NULL for current position. + * @param float $height Additional height to add. + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function isYOutRegion($posy = null, $height = 0, $pid = -1) - { + public function isYOutRegion( + ?float $posy = null, + float $height = 0.0, + int $pid = -1, + ): bool { if ($posy === null) { $posy = $this->getY(); } - return $this->isOutRegion(floatval($posy + $height), 'RY', 'RT', $pid); + + return $this->isOutRegion($posy + $height, 'RY', 'RT', $pid); } /** * Check if the specified horizontal position is outside the region. * - * @param float $posx X position or NULL for current position. - * @param float $width Additional width to add. - * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return boolean + * @param ?float $posx X position or NULL for current position. + * @param float $width Additional width to add. + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function isXOutRegion($posx = null, $width = 0, $pid = -1) - { + public function isXOutRegion( + ?float $posx = null, + float $width = 0.0, + int $pid = -1 + ): bool { if ($posx === null) { $posx = $this->getX(); } - return $this->isOutRegion(floatval($posx + $width), 'RX', 'RL', $pid); + + return $this->isOutRegion($posx + $width, 'RX', 'RL', $pid); } /** * Return the absolute horizontal cursor position for the current region. * * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return float */ - public function getX($pid = -1) + public function getX(int $pid = -1): float { $pid = $this->sanitizePageID($pid); return $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['x']; @@ -327,10 +839,8 @@ public function getX($pid = -1) * Return the absolute vertical cursor position for the current region. * * @param int $pid page index. Omit or set it to -1 for the current page ID. - * - * @return float */ - public function getY($pid = -1) + public function getY(int $pid = -1): float { $pid = $this->sanitizePageID($pid); return $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['y']; @@ -340,12 +850,12 @@ public function getY($pid = -1) * Set the absolute horizontal cursor position for the current region. * * @param float $xpos X position relative to the page coordinates. - * @param int $pid page index. Omit or set it to -1 for the current page ID. + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function setX($xpos, $pid = -1) + public function setX(float $xpos, int $pid = -1): static { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['x'] = floatval($xpos); + $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['x'] = $xpos; return $this; } @@ -353,12 +863,12 @@ public function setX($xpos, $pid = -1) * Set the absolute vertical cursor position for the current region. * * @param float $ypos Y position relative to the page coordinates. - * @param int $pid page index. Omit or set it to -1 for the current page ID. + * @param int $pid page index. Omit or set it to -1 for the current page ID. */ - public function setY($ypos, $pid = -1) + public function setY(float $ypos, int $pid = -1): static { $pid = $this->sanitizePageID($pid); - $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['y'] = floatval($ypos); + $this->page[$pid]['region'][$this->page[$pid]['currentRegion']]['y'] = $ypos; return $this; } } diff --git a/src/Settings.php b/src/Settings.php index a5cb3f8..4947cb8 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -3,32 +3,31 @@ /** * Settings.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Com\Tecnick\Pdf\Page; -use Com\Tecnick\Color\Pdf as Color; -use Com\Tecnick\Pdf\Page\Exception as PageException; +use Com\Tecnick\Pdf\Encrypt\Encrypt; /** * Com\Tecnick\Pdf\Page\Settings * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * @SuppressWarnings(PHPMD) */ @@ -37,155 +36,214 @@ abstract class Settings extends \Com\Tecnick\Pdf\Page\Box /** * Epsilon precision used to compare floating point values. */ - const EPS = 0.0001; + public const EPS = 0.0001; /** * Alias for total number of pages in a group. * * @var string */ - const PAGE_TOT = '~#PT'; + public const PAGE_TOT = '~#PT'; /** * Alias for page number. * * @var string */ - const PAGE_NUM = '~#PN'; + public const PAGE_NUM = '~#PN'; /** * Array of pages (stack). * - * @var array + * @var array, + * 'autobreak': bool, + * 'box': array, + * }, + * }>, + * 'columns': int, + * 'content': array, + * 'content_mark': array, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'currentRegion': int, + * 'format': string, + * 'group': int, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'n': int, + * 'num': int, + * 'orientation': string, + * 'pagenum': int, + * 'pheight': float, + * 'pid': int, + * 'pwidth': float, + * 'region': array, + * 'rotation': int, + * 'time': int, + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * 'width': float, + * 'zoom': float, + * }> */ - protected $page = array(); + protected array $page = []; /** * Current page ID. - * - * @var int */ - protected $pid = -1; + protected int $pid = -1; /** * Maximum page ID. - * - * @var int */ - protected $pmaxid = -1; + protected int $pmaxid = -1; /** * Count pages in each group. * - * @var array + * @var array */ - protected $group = array(0 => 0); + protected array $group = [ + 0 => 0, + ]; /** * Encrypt object. - * - * @var \Com\Tecnick\Pdf\Encrypt\Encrypt */ - protected $enc; + protected Encrypt $enc; /** * True if we are in PDF/A mode. - * - * @var bool */ - protected $pdfa = false; + protected bool $pdfa = false; /** * Enable stream compression. - * - * @var bool */ - protected $compress = true; + protected bool $compress = true; /** * True if the signature approval is enabled (for incremental updates). - * - * @var bool */ - protected $sigapp = false; + protected bool $sigapp = false; /** * Reserved Object ID for the resource dictionary. - * - * @var int */ - protected $rdoid = 1; + protected int $rdoid = 1; /** * Root object ID. - * - * @var int */ - protected $rootoid = 0; + protected int $rootoid = 0; /** * Sanitize or set the page modification time. * - * @param array $data Page data. + * @param array{ + * 'num': int, + * } $data Page data. */ - public function sanitizePageNumber(array &$data) + public function sanitizePageNumber(array &$data): void { - if (!empty($data['num'])) { - $data['num'] = max(0, intval($data['num'])); + if (! empty($data['num'])) { + $data['num'] = max(0, (int) $data['num']); } } /** * Sanitize or set the page modification time. * - * @param array $data Page data. + * @param array{ + * 'time': int, + * } $data Page data. */ - public function sanitizeTime(array &$data) + public function sanitizeTime(array &$data): void { - if (empty($data['time'])) { - $data['time'] = time(); - } else { - $data['time'] = max(0, intval($data['time'])); - } + $data['time'] = empty($data['time']) ? time() : max(0, (int) $data['time']); } /** * Sanitize or set the page group. * - * @param array $data Page data. + * @param array{ + * 'group': int, + * } $data Page data. */ - public function sanitizeGroup(array &$data) + public function sanitizeGroup(array &$data): void { - if (empty($data['group'])) { - $data['group'] = 0; - } else { - $data['group'] = max(0, intval($data['group'])); - } + $data['group'] = empty($data['group']) ? 0 : max(0, $data['group']); } /** * Sanitize or set the page content. * - * @param array $data Page data. + * @param array{ + * 'content': array, + * } $data Page data. */ - public function sanitizeContent(array &$data) + public function sanitizeContent(array &$data): void { if (empty($data['content'])) { - $data['content'] = array(''); - } else { - $data['content'] = array((string)$data['content']); + $data['content'] = ['']; + return; + } + + if (is_string($data['content'])) { + $data['content'] = [(string) $data['content']]; } } /** * Sanitize or set the annotation references. * - * @param array $data Page data. + * @param array{ + * 'annotrefs': array, + * } $data Page data. */ - public function sanitizeAnnotRefs(array &$data) + public function sanitizeAnnotRefs(array &$data): void { if (empty($data['annotrefs'])) { - $data['annotrefs'] = array(); + $data['annotrefs'] = []; } } @@ -194,49 +252,57 @@ public function sanitizeAnnotRefs(array &$data) * The number of degrees by which the page shall be rotated clockwise when displayed or printed. * The value shall be a multiple of 90. * - * @param array $data Page data. + * @param array{ + * 'rotation': int, + * } $data Page data. */ - public function sanitizeRotation(array &$data) + public function sanitizeRotation(array &$data): void { - if (empty($data['rotation']) || (($data['rotation'] % 90) != 0)) { - $data['rotation'] = 0; - } else { - $data['rotation'] = intval($data['rotation']); - } + $data['rotation'] = empty($data['rotation']) || ($data['rotation'] % 90 != 0) ? 0 : (int) $data['rotation']; } /** * Sanitize or set the page preferred zoom (magnification) factor. * - * @param array $data Page data. + * @param array{ + * 'zoom': float, + * } $data Page data. */ - public function sanitizeZoom(array &$data) + public function sanitizeZoom(array &$data): void { - if (empty($data['zoom'])) { - $data['zoom'] = 1; - } else { - $data['zoom'] = floatval($data['zoom']); - } + $data['zoom'] = empty($data['zoom']) ? 1 : $data['zoom']; } /** * Sanitize or set the page transitions. * - * @param array $data Page data. + * @param array{ + * 'transition': array{'B': bool, + * 'D': int, + * 'Di': string|int, + * 'Dm': string, + * 'Dur': float, + * 'M': string, + * 'S': string, + * 'SS': float, + * }, + * } $data Page data. */ - public function sanitizeTransitions(array &$data) + public function sanitizeTransitions(array &$data): void { if (empty($data['transition'])) { return; } + // display duration before advancing page if (empty($data['transition']['Dur'])) { unset($data['transition']['Dur']); } else { - $data['transition']['Dur'] = max(0, floatval($data['transition']['Dur'])); + $data['transition']['Dur'] = max(0, $data['transition']['Dur']); } + // transition style - $styles = array( + $styles = [ 'Split', 'Blinds', 'Box', @@ -248,72 +314,86 @@ public function sanitizeTransitions(array &$data) 'Push', 'Cover', 'Uncover', - 'Fade' - ); - if (empty($data['transition']['S']) || !in_array($data['transition']['S'], $styles)) { + 'Fade', + ]; + if (empty($data['transition']['S']) || ! in_array($data['transition']['S'], $styles)) { $data['transition']['S'] = 'R'; } + // duration of the transition effect, in seconds - if (!isset($data['transition']['D'])) { - $data['transition']['D'] = 1; - } else { - $data['transition']['D'] = intval($data['transition']['D']); - } + $data['transition']['D'] ??= 1; + // dimension in which the specified transition effect shall occur if ( empty($data['transition']['Dm']) - || !in_array($data['transition']['S'], array('Split', 'Blinds')) - || !in_array($data['transition']['Dm'], array('H', 'V')) + || ! in_array($data['transition']['S'], ['Split', 'Blinds']) + || ! in_array($data['transition']['Dm'], ['H', 'V']) ) { unset($data['transition']['Dm']); } + // direction of motion for the specified transition effect if ( empty($data['transition']['M']) - || !in_array($data['transition']['S'], array('Split', 'Box', 'Fly')) - || !in_array($data['transition']['M'], array('I', 'O')) + || ! in_array($data['transition']['S'], ['Split', 'Box', 'Fly']) + || ! in_array($data['transition']['M'], ['I', 'O']) ) { unset($data['transition']['M']); } + // direction in which the specified transition effect shall moves if ( empty($data['transition']['Di']) - || !in_array($data['transition']['S'], array('Wipe', 'Glitter', 'Fly', 'Cover', 'Uncover', 'Push')) - || !in_array($data['transition']['Di'], array('None', 0, 90, 180, 270, 315)) - || (in_array($data['transition']['Di'], array(90, 180)) && ($data['transition']['S'] != 'Wipe')) + || ! in_array($data['transition']['S'], ['Wipe', 'Glitter', 'Fly', 'Cover', 'Uncover', 'Push']) + || ! in_array($data['transition']['Di'], ['None', 0, 90, 180, 270, 315]) + || (in_array($data['transition']['Di'], [90, 180]) && ($data['transition']['S'] != 'Wipe')) || (($data['transition']['Di'] == 315) && ($data['transition']['S'] != 'Glitter')) || (($data['transition']['Di'] == 'None') && ($data['transition']['S'] != 'Fly')) ) { unset($data['transition']['Di']); } - // starting or ending scale at which the changes shall be drawn - if (isset($data['transition']['SS'])) { - $data['transition']['SS'] = floatval($data['transition']['SS']); - } + // If true, the area that shall be flown in is rectangular and opaque - if (empty($data['transition']['B'])) { - $data['transition']['B'] = false; - } else { - $data['transition']['B'] = true; - } + $data['transition']['B'] = ! empty($data['transition']['B']); } /** * Sanitize or set the page margins. * - * @param array $data Page data. + * @param array{ + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'FooterHeight': float, + * 'HeaderHeight': float, + * 'height': float, + * 'margin'?: array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'orientation': string, + * 'pheight': float, + * 'pwidth': float, + * 'width': float, + * } $data Page data. */ - public function sanitizeMargins(array &$data) + public function sanitizeMargins(array &$data): void { if (empty($data['margin'])) { - $data['margin'] = array(); + $data['margin'] = []; if (empty($data['width']) || empty($data['height'])) { - list($data['width'], $data['height'], $data['orientation']) = $this->getPageFormatSize('A4', 'P'); + [$data['width'], $data['height'], $data['orientation']] = $this->getPageFormatSize('A4', 'P'); $data['width'] /= $this->kunit; $data['height'] /= $this->kunit; } } - $margins = array( + + $margins = [ 'PL' => $data['width'], 'PR' => $data['width'], 'PT' => $data['height'], @@ -321,15 +401,14 @@ public function sanitizeMargins(array &$data) 'CT' => $data['height'], 'CB' => $data['height'], 'FT' => $data['height'], - 'PB' => $data['height'] - ); + 'PB' => $data['height'], + ]; foreach ($margins as $type => $max) { - if (empty($data['margin'][$type])) { - $data['margin'][$type] = 0; - } else { - $data['margin'][$type] = min(max(0, floatval($data['margin'][$type])), $max); - } + $data['margin'][$type] = ( + empty($data['margin'][$type]) + ) ? 0 : min(max(0, $data['margin'][$type]), $max); } + $data['margin']['PR'] = min($data['margin']['PR'], ($data['width'] - $data['margin']['PL'])); $data['margin']['HB'] = max($data['margin']['HB'], $data['margin']['PT']); $data['margin']['CT'] = max($data['margin']['CT'], $data['margin']['HB']); @@ -346,41 +425,70 @@ public function sanitizeMargins(array &$data) /** * Sanitize or set the page regions (columns). * - * @param array $data Page data. + * @param array{ + * 'autobreak'?: bool, + * 'columns'?: int, + * 'ContentHeight': float, + * 'ContentWidth': float, + * 'height': float, + * 'margin': array{ + * 'CB': float, + * 'CT': float, + * 'FT': float, + * 'HB': float, + * 'PB': float, + * 'PL': float, + * 'PR': float, + * 'PT': float, + * }, + * 'region'?: array, + * 'width': float, + * } $data Page data. */ - public function sanitizeRegions(array &$data) + public function sanitizeRegions(array &$data): void { - if (!empty($data['columns'])) { + if (! empty($data['columns'])) { // set eaual columns - $data['region'] = array(); + $data['region'] = []; $width = ($data['ContentWidth'] / $data['columns']); for ($idx = 0; $idx < $data['columns']; ++$idx) { - $data['region'][] = array( - 'RX' => ($data['margin']['PL'] + ($idx * $width)), - 'RY' => $data['margin']['CT'], - 'RW' => $width, - 'RH' => $data['ContentHeight'], - ); + $data['region'][] = [ + 'RX' => ($data['margin']['PL'] + ($idx * $width)), + 'RY' => $data['margin']['CT'], + 'RW' => $width, + 'RH' => $data['ContentHeight'], + ]; } } + if (empty($data['region'])) { // default single region - $data['region'] = array( - array( - 'RX' => $data['margin']['PL'], - 'RY' => $data['margin']['CT'], - 'RW' => $data['ContentWidth'], - 'RH' => $data['ContentHeight'], - ) - ); + $data['region'] = [[ + 'RX' => $data['margin']['PL'], + 'RY' => $data['margin']['CT'], + 'RW' => $data['ContentWidth'], + 'RH' => $data['ContentHeight'], + ]]; } + $data['columns'] = 0; // count the number of regions foreach ($data['region'] as $key => $val) { // region width - $data['region'][$key]['RW'] = min(max(0, floatval($val['RW'])), $data['ContentWidth']); + $data['region'][$key]['RW'] = min(max(0, $val['RW']), $data['ContentWidth']); // horizontal coordinate of the top-left corner $data['region'][$key]['RX'] = min( - max(0, floatval($val['RX'])), + max(0, $val['RX']), ($data['width'] - $data['margin']['PR'] - $val['RW']) ); // distance of the region right side from the left page edge @@ -388,10 +496,10 @@ public function sanitizeRegions(array &$data) // distance of the region right side from the right page edge $data['region'][$key]['RR'] = ($data['width'] - $val['RX'] - $val['RW']); // region height - $data['region'][$key]['RH'] = min(max(0, floatval($val['RH'])), $data['ContentHeight']); + $data['region'][$key]['RH'] = min(max(0, $val['RH']), $data['ContentHeight']); // vertical coordinate of the top-left corner $data['region'][$key]['RY'] = min( - max(0, floatval($val['RY'])), + max(0, $val['RY']), ($data['height'] - $data['margin']['CB'] - $val['RH']) ); // distance of the region bottom side from the top page edge @@ -406,7 +514,7 @@ public function sanitizeRegions(array &$data) ++$data['columns']; } - if (!isset($data['autobreak'])) { + if (! isset($data['autobreak'])) { $data['autobreak'] = true; } } @@ -414,25 +522,47 @@ public function sanitizeRegions(array &$data) /** * Sanitize or set the page boxes containing the page boundaries. * - * @param array $data Page data. + * @param array{ + * 'box'?: array, + * }, + * }>, + * 'format'?: string, + * 'height': float, + * 'orientation': string, + * 'pheight'?: float, + * 'pwidth'?: float, + * 'width': float, + * } $data Page data. */ - public function sanitizeBoxData(array &$data) + public function sanitizeBoxData(array &$data): void { if (empty($data['box'])) { if (empty($data['pwidth']) || empty($data['pheight'])) { - list($data['pwidth'], $data['pheight'], $data['orientation']) = $this->getPageFormatSize('A4', 'P'); + [$data['pwidth'], $data['pheight'], $data['orientation']] = $this->getPageFormatSize('A4', 'P'); } + $data['box'] = $this->setPageBoxes($data['pwidth'], $data['pheight']); } else { - if (!empty($data['format']) && ($data['format'] == 'MediaBox')) { + if (isset($data['format']) && $data['format'] !== '' && ($data['format'] == 'MediaBox')) { $data['format'] = ''; $data['width'] = abs($data['box']['MediaBox']['urx'] - $data['box']['MediaBox']['llx']) / $this->kunit; $data['height'] = abs($data['box']['MediaBox']['ury'] - $data['box']['MediaBox']['lly']) / $this->kunit; $this->sanitizePageFormat($data); } + if (empty($data['box']['MediaBox'])) { $data['box'] = $this->setBox($data['box'], 'MediaBox', 0, 0, $data['pwidth'], $data['pheight']); } + if (empty($data['box']['CropBox'])) { $data['box'] = $this->setBox( $data['box'], @@ -443,6 +573,7 @@ public function sanitizeBoxData(array &$data) $data['box']['MediaBox']['ury'] ); } + if (empty($data['box']['BleedBox'])) { $data['box'] = $this->setBox( $data['box'], @@ -453,6 +584,7 @@ public function sanitizeBoxData(array &$data) $data['box']['CropBox']['ury'] ); } + if (empty($data['box']['TrimBox'])) { $data['box'] = $this->setBox( $data['box'], @@ -463,6 +595,7 @@ public function sanitizeBoxData(array &$data) $data['box']['CropBox']['ury'] ); } + if (empty($data['box']['ArtBox'])) { $data['box'] = $this->setBox( $data['box'], @@ -474,6 +607,7 @@ public function sanitizeBoxData(array &$data) ); } } + $orientation = $this->getPageOrientation( abs($data['box']['MediaBox']['urx'] - $data['box']['MediaBox']['llx']), abs($data['box']['MediaBox']['ury'] - $data['box']['MediaBox']['lly']) @@ -488,15 +622,23 @@ public function sanitizeBoxData(array &$data) /** * Sanitize or set the page format. * - * @param array $data Page data. + * @param array{ + * 'format': string, + * 'height': float, + * 'orientation': string, + * 'pheight': float, + * 'pwidth': float, + * 'width': float, + * } $data Page data. */ - public function sanitizePageFormat(array &$data) + public function sanitizePageFormat(array &$data): void { if (empty($data['orientation'])) { $data['orientation'] = ''; } - if (!empty($data['format'])) { - list($data['pwidth'], $data['pheight'], $data['orientation']) = $this->getPageFormatSize( + + if (! empty($data['format'])) { + [$data['pwidth'], $data['pheight'], $data['orientation']] = $this->getPageFormatSize( $data['format'], $data['orientation'] ); @@ -505,22 +647,20 @@ public function sanitizePageFormat(array &$data) } else { $data['format'] = 'CUSTOM'; if (empty($data['width']) || empty($data['height'])) { - if (empty($data['box']['MediaBox'])) { - // default page format - $data['format'] = 'A4'; - $data['orientation'] = 'P'; - return $this->sanitizePageFormat($data); - } - $data['format'] = 'MediaBox'; + // default page format + $data['format'] = 'A4'; + $data['orientation'] = 'P'; + $this->sanitizePageFormat($data); return; - } else { - list($data['width'], $data['height'], $data['orientation']) = $this->getPageOrientedSize( - $data['width'], - $data['height'], - $data['orientation'] - ); } + + [$data['width'], $data['height'], $data['orientation']] = $this->getPageOrientedSize( + $data['width'], + $data['height'], + $data['orientation'] + ); } + // convert values in points $data['pwidth'] = ($data['width'] * $this->kunit); $data['pheight'] = ($data['height'] * $this->kunit); diff --git a/test/BoxTest.php b/test/BoxTest.php index 3071a45..f6ae36e 100644 --- a/test/BoxTest.php +++ b/test/BoxTest.php @@ -3,135 +3,150 @@ /** * BoxTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Box Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class BoxTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false); } - public function testSetBox() + public function testSetBox(): void { - $testObj = $this->getTestObject(); - $dims = $testObj->setBox(array(), 'CropBox', 2, 4, 6, 8); + $page = $this->getTestObject(); + $dims = $page->setBox([], 'CropBox', 2, 4, 6, 8); $this->bcAssertEqualsWithDelta( - array( - 'CropBox' => array( + [ + 'CropBox' => [ 'llx' => 2, 'lly' => 4, 'urx' => 6, 'ury' => 8, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(3), - ) - ) - ), + 'dash' => [3], + ], + ], + ], $dims ); - $dims = $testObj->setBox( - array(), + $dims = $page->setBox( + [], 'TrimBox', 3, 5, 7, 11, - array( + [ 'color' => 'aquamarine', 'width' => 2, 'style' => 'D', - 'dash' => array(2,3,5,7), - ) + 'dash' => [2, 3, 5, 7], + ] ); $this->bcAssertEqualsWithDelta( - array( - 'TrimBox' => array( + [ + 'TrimBox' => [ 'llx' => 3, 'lly' => 5, 'urx' => 7, 'ury' => 11, - 'bci' => array( + 'bci' => [ 'color' => 'aquamarine', 'width' => 2, 'style' => 'D', - 'dash' => array(2,3,5,7), - ) - ) - ), + 'dash' => [2, 3, 5, 7], + ], + ], + ], $dims ); } - public function testSetBoxEx() + public function testSetBoxEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->setBox(array(), 'ERROR', 1, 2, 3, 4); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->setBox([], 'ERROR', 1, 2, 3, 4); } - public function testSwapCoordinates() + public function testSwapCoordinates(): void { - $testObj = $this->getTestObject(); - $dims = array('CropBox' => array('llx' => 2, 'lly' => 4, 'urx' => 6, 'ury' => 8)); - $newpagedim = $testObj->swapCoordinates($dims); - $this->assertEquals(array('CropBox' => array('llx' => 4, 'lly' => 2, 'urx' => 8, 'ury' => 6)), $newpagedim); + $page = $this->getTestObject(); + $dims = [ + 'CropBox' => [ + 'llx' => 2, + 'lly' => 4, + 'urx' => 6, + 'ury' => 8, + ], + ]; + $newpagedim = $page->swapCoordinates($dims); + $this->assertEquals( + [ + 'CropBox' => [ + 'llx' => 4, + 'lly' => 2, + 'urx' => 8, + 'ury' => 6, + ], + ], + $newpagedim + ); } - public function testSetPageBoxes() + public function testSetPageBoxes(): void { - $testObj = $this->getTestObject(); - $dims = $testObj->setPageBoxes(100, 200); - $exp = array( + $page = $this->getTestObject(); + $dims = $page->setPageBoxes(100, 200); + $exp = [ 'llx' => 0, 'lly' => 0, 'urx' => 100, 'ury' => 200, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array (3), - ) - ); + 'dash' => [3], + ], + ]; $this->bcAssertEqualsWithDelta( - array( + [ 'MediaBox' => $exp, - 'CropBox' => $exp, + 'CropBox' => $exp, 'BleedBox' => $exp, - 'TrimBox' => $exp, - 'ArtBox' => $exp, - ), + 'TrimBox' => $exp, + 'ArtBox' => $exp, + ], $dims ); } diff --git a/test/FormatTest.php b/test/FormatTest.php index 6fa69ac..e46c262 100644 --- a/test/FormatTest.php +++ b/test/FormatTest.php @@ -3,96 +3,94 @@ /** * FormatTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Format Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class FormatTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false); } - public function testGetPageSize() + public function testGetPageSize(): void { - $testObj = $this->getTestObject(); - $dims = $testObj->getPageFormatSize('A0'); - $this->assertEquals(array(2383.937, 3370.394, 'P'), $dims); + $page = $this->getTestObject(); + $dims = $page->getPageFormatSize('A0'); + $this->assertEquals([2383.937, 3370.394, 'P'], $dims); - $dims = $testObj->getPageFormatSize('A4', '', 'in', 2); - $this->assertEquals(array(8.27, 11.69, 'P'), $dims); + $dims = $page->getPageFormatSize('A4', '', 'in', 2); + $this->assertEquals([8.27, 11.69, 'P'], $dims); - $dims = $testObj->getPageFormatSize('LEGAL', '', 'mm', 0); - $this->assertEquals(array(216, 356, 'P'), $dims); + $dims = $page->getPageFormatSize('LEGAL', '', 'mm', 0); + $this->assertEquals([216, 356, 'P'], $dims); - $dims = $testObj->getPageFormatSize('LEGAL', 'P', 'mm', 0); - $this->assertEquals(array(216, 356, 'P'), $dims); + $dims = $page->getPageFormatSize('LEGAL', 'P', 'mm', 0); + $this->assertEquals([216, 356, 'P'], $dims); - $dims = $testObj->getPageFormatSize('LEGAL', 'L', 'mm', 0); - $this->assertEquals(array(356, 216, 'L'), $dims); + $dims = $page->getPageFormatSize('LEGAL', 'L', 'mm', 0); + $this->assertEquals([356, 216, 'L'], $dims); } - public function testGetPageSizeEx() + public function testGetPageSizeEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->getPageFormatSize('*ERROR*'); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->getPageFormatSize('*ERROR*'); } - public function testGetPageOrientedSize() + public function testGetPageOrientedSize(): void { - $testObj = $this->getTestObject(); - $dims = $testObj->getPageOrientedSize(10, 20); - $this->assertEquals(array(10, 20, 'P'), $dims); + $page = $this->getTestObject(); + $dims = $page->getPageOrientedSize(10, 20); + $this->assertEquals([10, 20, 'P'], $dims); - $dims = $testObj->getPageOrientedSize(10, 20, 'P'); - $this->assertEquals(array(10, 20, 'P'), $dims); + $dims = $page->getPageOrientedSize(10, 20, 'P'); + $this->assertEquals([10, 20, 'P'], $dims); - $dims = $testObj->getPageOrientedSize(10, 20, 'L'); - $this->assertEquals(array(20, 10, 'L'), $dims); + $dims = $page->getPageOrientedSize(10, 20, 'L'); + $this->assertEquals([20, 10, 'L'], $dims); - $dims = $testObj->getPageOrientedSize(20, 10, 'P'); - $this->assertEquals(array(10, 20, 'P'), $dims); + $dims = $page->getPageOrientedSize(20, 10, 'P'); + $this->assertEquals([10, 20, 'P'], $dims); - $dims = $testObj->getPageOrientedSize(20, 10, 'L'); - $this->assertEquals(array(20, 10, 'L'), $dims); + $dims = $page->getPageOrientedSize(20, 10, 'L'); + $this->assertEquals([20, 10, 'L'], $dims); - $dims = $testObj->getPageOrientedSize(20, 10); - $this->assertEquals(array(20, 10, 'L'), $dims); + $dims = $page->getPageOrientedSize(20, 10); + $this->assertEquals([20, 10, 'L'], $dims); } - public function testGetPageOrientation() + public function testGetPageOrientation(): void { - $testObj = $this->getTestObject(); - $orient = $testObj->getPageOrientation(10, 20); + $page = $this->getTestObject(); + $orient = $page->getPageOrientation(10, 20); $this->assertEquals('P', $orient); - $orient = $testObj->getPageOrientation(20, 10); + $orient = $page->getPageOrientation(20, 10); $this->assertEquals('L', $orient); } } diff --git a/test/ModeTest.php b/test/ModeTest.php index a546c1c..e7cf5d3 100644 --- a/test/ModeTest.php +++ b/test/ModeTest.php @@ -3,54 +3,52 @@ /** * ModeTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Mode Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class ModeTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false); } - public function testGetLayout() + public function testGetLayout(): void { - $testObj = $this->getTestObject(); - $this->assertEquals('TwoColumnLeft', $testObj->getLayout('two')); - $this->assertEquals('SinglePage', $testObj->getLayout('')); - $this->assertEquals('SinglePage', $testObj->getLayout()); + $page = $this->getTestObject(); + $this->assertEquals('TwoColumnLeft', $page->getLayout('two')); + $this->assertEquals('SinglePage', $page->getLayout('')); + $this->assertEquals('SinglePage', $page->getLayout()); } - public function testGetDisplay() + public function testGetDisplay(): void { - $testObj = $this->getTestObject(); - $this->assertEquals('UseThumbs', $testObj->getDisplay('usethumbs')); - $this->assertEquals('UseAttachments', $testObj->getDisplay('')); - $this->assertEquals('UseNone', $testObj->getDisplay('something')); + $page = $this->getTestObject(); + $this->assertEquals('UseThumbs', $page->getDisplay('usethumbs')); + $this->assertEquals('UseAttachments', $page->getDisplay('')); + $this->assertEquals('UseNone', $page->getDisplay('something')); } } diff --git a/test/PageTest.php b/test/PageTest.php index a139737..b41283a 100644 --- a/test/PageTest.php +++ b/test/PageTest.php @@ -3,74 +3,74 @@ /** * PageTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Page Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class PageTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, true, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, true, false); } - public function testGetKUnit() + public function testGetKUnit(): void { - $testObj = $this->getTestObject(); - $this->bcAssertEqualsWithDelta(2.83464566929134, $testObj->getKUnit(), 0.001); + $page = $this->getTestObject(); + $this->bcAssertEqualsWithDelta(2.83464566929134, $page->getKUnit(), 0.001); } - public function testEnableSignatureApproval() + public function testEnableSignatureApproval(): void { - $testObj = $this->getTestObject(); - $res = $testObj->enableSignatureApproval(true); + $page = $this->getTestObject(); + $res = $page->enableSignatureApproval(true); $this->assertNotNull($res); } - public function testAdd() + public function testAdd(): void { - $testObj = $this->getTestObject(); + $page = $this->getTestObject(); // 1 - $res = $testObj->add(); + $res = $page->add(); - $box = array( + $box = [ 'llx' => 0, 'lly' => 0, 'urx' => 595.2765, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ); + 'dash' => [ + 0 => 3, + ], + ], + ]; - $exp = array( + $exp = [ 'group' => 0, 'rotation' => 0, 'zoom' => 1, @@ -80,14 +80,14 @@ public function testAdd() 'pwidth' => 595.2765, 'width' => 210, 'height' => 297, - 'box' => array( + 'box' => [ 'MediaBox' => $box, - 'CropBox' => $box, + 'CropBox' => $box, 'BleedBox' => $box, - 'TrimBox' => $box, - 'ArtBox' => $box, - ), - 'margin' => array( + 'TrimBox' => $box, + 'ArtBox' => $box, + ], + 'margin' => [ 'PL' => 0, 'PR' => 0, 'PT' => 0, @@ -96,58 +96,68 @@ public function testAdd() 'CB' => 0, 'FT' => 0, 'PB' => 0, - ), + ], 'ContentWidth' => 210, 'ContentHeight' => 297, 'HeaderHeight' => 0, 'FooterHeight' => 0, - 'region' => array ( - array ( - 'RX' => 0, - 'RY' => 0, - 'RW' => 210, - 'RH' => 297, - 'RL' => 210, - 'RR' => 0.0, - 'RT' => 297, - 'RB' => 0.0, - 'x' => 0.0, - 'y' => 0.0, - ), - ), + 'region' => [[ + 'RX' => 0, + 'RY' => 0, + 'RW' => 210, + 'RH' => 297, + 'RL' => 210, + 'RR' => 0.0, + 'RT' => 297, + 'RB' => 0.0, + 'x' => 0.0, + 'y' => 0.0, + ]], 'currentRegion' => 0, 'columns' => 1, - 'content' => array(0 => ''), - 'annotrefs' => array(), - 'content_mark' => array(0 => 0), + 'content' => [ + 0 => '', + ], + 'annotrefs' => [], + 'content_mark' => [ + 0 => 0, + ], 'autobreak' => true, - ); + ]; unset($res['time']); $exp['pid'] = 0; $this->bcAssertEqualsWithDelta($exp, $res); // 2 - $res = $testObj->add(); + $res = $page->add(); unset($res['time']); $exp['pid'] = 1; $this->bcAssertEqualsWithDelta($exp, $res); // 3 - $res = $testObj->add(array('group' => 1)); + $res = $page->add( + [ + 'group' => 1, + ] + ); unset($res['time']); $exp['pid'] = 2; $exp['group'] = 1; $this->bcAssertEqualsWithDelta($exp, $res); // 3 - $res = $testObj->add(array('columns' => 2)); + $res = $page->add( + [ + 'columns' => 2, + ] + ); unset($res['time']); $exp['pid'] = 3; $exp['group'] = 0; $exp['columns'] = 2; - $exp['region'] = array ( - 0 => array ( + $exp['region'] = [ + 0 => [ 'RX' => 0, 'RY' => 0, 'RW' => 105, @@ -156,10 +166,10 @@ public function testAdd() 'RR' => 105, 'RT' => 297, 'RB' => 0, - 'x' => 0, - 'y' => 0, - ), - 1 => array ( + 'x' => 0, + 'y' => 0, + ], + 1 => [ 'RX' => 105, 'RY' => 0, 'RW' => 105, @@ -168,95 +178,107 @@ public function testAdd() 'RR' => 0.0, 'RT' => 297, 'RB' => 0, - 'x' => 105, - 'y' => 0, - ), - ); + 'x' => 105, + 'y' => 0, + ], + ]; $this->bcAssertEqualsWithDelta($exp, $res); } - public function testGetNextPage() + public function testGetNextPage(): void { - $testObj = $this->getTestObject(); - $testObj->add(); - $testObj->add(); - $testObj->add(); - $testObj->add(); + $page = $this->getTestObject(); + $page->add(); + $page->add(); + $page->add(); + $page->add(); - $testObj->setCurrentPage(2); - $testObj->getNextPage(); - $testObj->enableAutoPageBreak(false); - $testObj->getNextPage(); - $testObj->enableAutoPageBreak(true); - $testObj->getNextPage(); - $testObj->getNextPage(); + $page->setCurrentPage(2); + $page->getNextPage(); + $page->enableAutoPageBreak(false); + $page->getNextPage(); + $page->enableAutoPageBreak(true); + $page->getNextPage(); + $page->getNextPage(); - $this->assertCount(6, $testObj->getPages()); + $this->assertCount(6, $page->getPages()); } - public function testDelete() + public function testDelete(): void { - $testObj = $this->getTestObject(); - $testObj->add(); - $testObj->add(); - $testObj->add(); - $this->assertCount(3, $testObj->getPages()); - $res = $testObj->delete(1); - $this->assertCount(2, $testObj->getPages()); + $page = $this->getTestObject(); + $page->add(); + $page->add(); + $page->add(); + $this->assertCount(3, $page->getPages()); + $res = $page->delete(1); + $this->assertCount(2, $page->getPages()); $this->assertArrayHasKey('time', $res); } - public function testDeleteEx() + public function testDeleteEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->delete(2); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->delete(2); } - public function testPop() + public function testPop(): void { - $testObj = $this->getTestObject(); - $testObj->add(); - $testObj->add(); - $testObj->add(); - $this->assertCount(3, $testObj->getPages()); - $res = $testObj->pop(); - $this->assertCount(2, $testObj->getPages()); + $page = $this->getTestObject(); + $page->add(); + $page->add(); + $page->add(); + $this->assertCount(3, $page->getPages()); + $res = $page->pop(); + $this->assertCount(2, $page->getPages()); $this->assertArrayHasKey('time', $res); } - public function testMove() + public function testMove(): void { - $testObj = $this->getTestObject(); - $testObj->add(); - $testObj->add(array('group' => 1)); - $testObj->add(array('group' => 2)); - $testObj->add(array('group' => 3)); + $page = $this->getTestObject(); + $page->add(); + $page->add( + [ + 'group' => 1, + ] + ); + $page->add( + [ + 'group' => 2, + ] + ); + $page->add( + [ + 'group' => 3, + ] + ); - $this->assertEquals($testObj->getPage(3), $testObj->getPage()); + $this->assertEquals($page->getPage(3), $page->getPage()); - $testObj->move(3, 0); - $this->assertCount(4, $testObj->getPages()); + $page->move(3, 0); + $this->assertCount(4, $page->getPages()); - $res = $testObj->getPage(0); + $res = $page->getPage(0); $this->assertEquals(3, $res['group']); } - public function testMoveEx() + public function testMoveEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->move(1, 2); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->move(1, 2); } - public function testGetPageEx() + public function testGetPageEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->getPage(2); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->getPage(2); } - public function testContent() + public function testContent(): void { $testObj = $this->getTestObject(); $testObj->add(); @@ -270,26 +292,26 @@ public function testContent() $this->assertEquals('amet', $testObj->popContent()); $page = $testObj->getPage(); - $this->assertEquals(array(0, 3), $page['content_mark']); - $this->assertEquals(array('', 'Lorem', 'ipsum', 'dolor', 'sit'), $page['content']); + $this->assertEquals([0, 3], $page['content_mark']); + $this->assertEquals(['', 'Lorem', 'ipsum', 'dolor', 'sit'], $page['content']); $testObj->popContentToLastMark(); $page = $testObj->getPage(); - $this->assertEquals(array(0), $page['content_mark']); - $this->assertEquals(array('', 'Lorem', 'ipsum'), $page['content']); + $this->assertEquals([0], $page['content_mark']); + $this->assertEquals(['', 'Lorem', 'ipsum'], $page['content']); } - public function testGetPdfPages() + public function testGetPdfPages(): void { - $testObj = $this->getTestObject(); - $testObj->add(); - $testObj->addContent('TEST1'); - $testObj->add(); - $testObj->addContent('TEST2'); - $testObj->add( - array( + $page = $this->getTestObject(); + $page->add(); + $page->addContent('TEST1'); + $page->add(); + $page->addContent('TEST2'); + $page->add( + [ 'group' => 1, - 'transition' => array( + 'transition' => [ 'Dur' => 2, 'D' => 3, 'Dm' => 'V', @@ -297,25 +319,27 @@ public function testGetPdfPages() 'M' => 'O', 'Di' => 315, 'SS' => 1.3, - 'B' => true - ), - 'annotrefs' => array(10, 20), - ) + 'B' => true, + ], + 'annotrefs' => [10, 20], + ] ); - $testObj->addContent('TEST2'); + $page->addContent('TEST2'); + $pon = 0; - $out = $testObj->getPdfPages($pon); - $this->assertEquals(1, $testObj->getResourceDictObjID()); - $this->assertEquals(2, $testObj->getRootObjID()); + $out = $page->getPdfPages($pon); + $this->assertEquals(1, $page->getResourceDictObjID()); + $this->assertEquals(2, $page->getRootObjID()); $this->bcAssertStringContainsString('<< /Type /Pages /Kids [ 3 0 R 4 0 R 5 0 R ] /Count 3 >>', $out); } - public function testaddAnnotRef() + public function testaddAnnotRef(): void { $testObj = $this->getTestObject(); $testObj->add(); $testObj->addAnnotRef(13); $testObj->addAnnotRef(17); + $page = $testObj->getPage(); $this->assertEquals(13, $page['annotrefs'][0]); $this->assertEquals(17, $page['annotrefs'][1]); diff --git a/test/RegionTest.php b/test/RegionTest.php index fead0e2..7b33187 100644 --- a/test/RegionTest.php +++ b/test/RegionTest.php @@ -3,47 +3,54 @@ /** * RegionTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; +use Com\Tecnick\Color\Pdf; +use Com\Tecnick\Pdf\Encrypt\Encrypt; +use Com\Tecnick\Pdf\Page\Page; /** * Page Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class RegionTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new Pdf(); + $encrypt = new Encrypt(false); + return new Page('mm', $pdf, $encrypt, false, false); } - public function testRegion() + public function testRegion(): void { - $testObj = $this->getTestObject(); - $testObj->add(array('columns' => 3)); - $res = $testObj->selectRegion(1); - $exp = array( + $page = $this->getTestObject(); + $page->add( + [ + 'columns' => 3, + ] + ); + + $res = $page->selectRegion(1); + $exp = [ 'RX' => 70, 'RY' => 0, 'RW' => 70, @@ -52,76 +59,81 @@ public function testRegion() 'RR' => 70, 'RT' => 297, 'RB' => 0, - 'x' => 70, - 'y' => 0, - ); + 'x' => 70, + 'y' => 0, + ]; $this->bcAssertEqualsWithDelta($exp, $res); - $res = $testObj->getRegion(); + $res = $page->getRegion(); $this->bcAssertEqualsWithDelta($exp, $res); - $res = $testObj->getNextRegion(); + $res = $page->getNextRegion(); $this->bcAssertEqualsWithDelta(2, $res['currentRegion']); - $res = $testObj->getNextRegion(); + $res = $page->getNextRegion(); $this->bcAssertEqualsWithDelta(0, $res['currentRegion']); - $testObj->setCurrentPage(0); - $res = $testObj->getNextRegion(); + $page->setCurrentPage(0); + $res = $page->getNextRegion(); $this->bcAssertEqualsWithDelta(0, $res['currentRegion']); - $res = $testObj->checkRegionBreak(1000); + $res = $page->checkRegionBreak(1000); $this->bcAssertEqualsWithDelta(1, $res['currentRegion']); - $res = $testObj->checkRegionBreak(); + $res = $page->checkRegionBreak(); $this->bcAssertEqualsWithDelta(1, $res['currentRegion']); - $testObj->setX(13)->setY(17); - $this->bcAssertEqualsWithDelta(13, $testObj->getX()); - $this->bcAssertEqualsWithDelta(17, $testObj->getY()); + $page->setX(13)->setY(17); + $this->bcAssertEqualsWithDelta(13, $page->getX()); + $this->bcAssertEqualsWithDelta(17, $page->getY()); } - public function testRegionBoundaries() + public function testRegionBoundaries(): void { - $testObj = $this->getTestObject(); - $testObj->add(array('columns' => 3)); - $region = $testObj->getRegion(); + $page = $this->getTestObject(); + $page->add( + [ + 'columns' => 3, + ] + ); + + $region = $page->getRegion(); - $res = $testObj->isYOutRegion(null, 1); + $res = $page->isYOutRegion(null, 1); $this->assertFalse($res); - $res = $testObj->isYOutRegion(-1); + $res = $page->isYOutRegion(-1); $this->assertTrue($res); - $res = $testObj->isYOutRegion($region['RY']); + $res = $page->isYOutRegion($region['RY']); $this->assertFalse($res); - $res = $testObj->isYOutRegion(0); + $res = $page->isYOutRegion(0); $this->assertFalse($res); - $res = $testObj->isYOutRegion(100); + $res = $page->isYOutRegion(100); $this->assertFalse($res); - $res = $testObj->isYOutRegion(297); + $res = $page->isYOutRegion(297); $this->assertFalse($res); - $res = $testObj->isYOutRegion($region['RT']); + $res = $page->isYOutRegion($region['RT']); $this->assertFalse($res); - $res = $testObj->isYOutRegion(298); + $res = $page->isYOutRegion(298); $this->assertTrue($res); - $testObj->getNextRegion(); - $region = $testObj->getRegion(); + $page->getNextRegion(); + $region = $page->getRegion(); - $res = $testObj->isXOutRegion(null, 1); + $res = $page->isXOutRegion(null, 1); $this->assertFalse($res); - $res = $testObj->isXOutRegion(69); + $res = $page->isXOutRegion(69); $this->assertTrue($res); - $res = $testObj->isXOutRegion($region['RX']); + $res = $page->isXOutRegion($region['RX']); $this->assertFalse($res); - $res = $testObj->isXOutRegion(70); + $res = $page->isXOutRegion(70); $this->assertFalse($res); - $res = $testObj->isXOutRegion(90); + $res = $page->isXOutRegion(90); $this->assertFalse($res); - $res = $testObj->isXOutRegion(140); + $res = $page->isXOutRegion(140); $this->assertFalse($res); - $res = $testObj->isXOutRegion($region['RL']); + $res = $page->isXOutRegion($region['RL']); $this->assertFalse($res); - $res = $testObj->isXOutRegion(141); + $res = $page->isXOutRegion(141); $this->assertTrue($res); } } diff --git a/test/SettingsTest.php b/test/SettingsTest.php index dcf1d43..ce80585 100644 --- a/test/SettingsTest.php +++ b/test/SettingsTest.php @@ -3,189 +3,326 @@ /** * SettingsTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Settings Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class SettingsTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false); } - public function testSanitizePageNumber() + public function testSanitizePageNumber(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizePageNumber($data); - $this->assertEquals(array(), $data); - - $data = array('num' => -1); - $testObj->sanitizePageNumber($data); - $this->assertEquals(array('num' => 0), $data); - - - $data = array('num' => 0); - $testObj->sanitizePageNumber($data); - $this->assertEquals(array('num' => 0), $data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizePageNumber($data); + $this->assertEquals([], $data); + + $data = [ + 'num' => -1, + ]; + $page->sanitizePageNumber($data); + $this->assertEquals( + [ + 'num' => 0, + ], + $data + ); + $data = [ + 'num' => 0, + ]; + $page->sanitizePageNumber($data); + $this->assertEquals( + [ + 'num' => 0, + ], + $data + ); - $data = array('num' => 1); - $testObj->sanitizePageNumber($data); - $this->assertEquals(array('num' => 1), $data); + $data = [ + 'num' => 1, + ]; + $page->sanitizePageNumber($data); + $this->assertEquals( + [ + 'num' => 1, + ], + $data + ); } - public function testSanitizeTime() + public function testSanitizeTime(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeTime($data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizeTime($data); $this->assertNotEmpty($data['time']); /* @phpstan-ignore-line */ - $data = array('time' => -1); - $testObj->sanitizeTime($data); - $this->assertEquals(array('time' => 0), $data); + $data = [ + 'time' => -1, + ]; + $page->sanitizeTime($data); + $this->assertEquals( + [ + 'time' => 0, + ], + $data + ); - $data = array('time' => 0); - $testObj->sanitizeTime($data); + $data = [ + 'time' => 0, + ]; + $page->sanitizeTime($data); $this->assertNotEmpty($data['time']); - $data = array('time' => 1); - $testObj->sanitizeTime($data); - $this->assertEquals(array('time' => 1), $data); + $data = [ + 'time' => 1, + ]; + $page->sanitizeTime($data); + $this->assertEquals( + [ + 'time' => 1, + ], + $data + ); } - public function testSanitizeGroup() + public function testSanitizeGroup(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeGroup($data); - $this->assertEquals(array('group' => 0), $data); - - $data = array('group' => -1); - $testObj->sanitizeGroup($data); - $this->assertEquals(array('group' => 0), $data); - + $page = $this->getTestObject(); + $data = []; + $page->sanitizeGroup($data); + $this->assertEquals( + [ + 'group' => 0, + ], + $data + ); - $data = array('group' => 0); - $testObj->sanitizeGroup($data); - $this->assertEquals(array('group' => 0), $data); + $data = [ + 'group' => -1, + ]; + $page->sanitizeGroup($data); + $this->assertEquals( + [ + 'group' => 0, + ], + $data + ); + $data = [ + 'group' => 0, + ]; + $page->sanitizeGroup($data); + $this->assertEquals( + [ + 'group' => 0, + ], + $data + ); - $data = array('group' => 1); - $testObj->sanitizeGroup($data); - $this->assertEquals(array('group' => 1), $data); + $data = [ + 'group' => 1, + ]; + $page->sanitizeGroup($data); + $this->assertEquals( + [ + 'group' => 1, + ], + $data + ); } - public function testSanitizeContent() + public function testSanitizeContent(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeContent($data); - $this->assertEquals(array('content' => array('')), $data); - - $data = array('content' => 'test'); - $testObj->sanitizeContent($data); - $this->assertEquals(array('content' => array('test')), $data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizeContent($data); + $this->assertEquals( + [ + 'content' => [''], + ], + $data + ); + + $data = [ + 'content' => 'test', + ]; + $page->sanitizeContent($data); + $this->assertEquals( + [ + 'content' => ['test'], + ], + $data + ); } - public function testSanitizeAnnotRefs() + public function testSanitizeAnnotRefs(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeAnnotRefs($data); - $this->assertEquals(array('annotrefs' => array()), $data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizeAnnotRefs($data); + $this->assertEquals( + [ + 'annotrefs' => [], + ], + $data + ); } - public function testSanitizeRotation() + public function testSanitizeRotation(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 0), $data); - - $data = array('rotation' => 0); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 0), $data); - - $data = array('rotation' => 100); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 0), $data); - - $data = array('rotation' => 90); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 90), $data); - - $data = array('rotation' => 180); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 180), $data); - - $data = array('rotation' => 270); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 270), $data); - - $data = array('rotation' => 360); - $testObj->sanitizeRotation($data); - $this->assertEquals(array('rotation' => 360), $data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 0, + ], + $data + ); + + $data = [ + 'rotation' => 0, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 0, + ], + $data + ); + + $data = [ + 'rotation' => 100, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 0, + ], + $data + ); + + $data = [ + 'rotation' => 90, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 90, + ], + $data + ); + + $data = [ + 'rotation' => 180, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 180, + ], + $data + ); + + $data = [ + 'rotation' => 270, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 270, + ], + $data + ); + + $data = [ + 'rotation' => 360, + ]; + $page->sanitizeRotation($data); + $this->assertEquals( + [ + 'rotation' => 360, + ], + $data + ); } - public function testSanitizeZoom() + public function testSanitizeZoom(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeZoom($data); - $this->assertEquals(array('zoom' => 1), $data); - - $data = array('zoom' => 1.2); - $testObj->sanitizeZoom($data); - $this->assertEquals(array('zoom' => 1.2), $data); + $page = $this->getTestObject(); + $data = []; + $page->sanitizeZoom($data); + $this->assertEquals( + [ + 'zoom' => 1, + ], + $data + ); + + $data = [ + 'zoom' => 1.2, + ]; + $page->sanitizeZoom($data); + $this->assertEquals( + [ + 'zoom' => 1.2, + ], + $data + ); } - public function testSanitizeTransitions() + public function testSanitizeTransitions(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeTransitions($data); - $this->assertEquals(array(), $data); - - $data = array('transition' => array('Dur' => 0)); - $testObj->sanitizeTransitions($data); - $exp = array( - 'transition' => array( + $page = $this->getTestObject(); + $data = []; + $page->sanitizeTransitions($data); + $this->assertEquals([], $data); + + $data = [ + 'transition' => [ + 'Dur' => 0, + ], + ]; + $page->sanitizeTransitions($data); + $exp = [ + 'transition' => [ 'S' => 'R', 'D' => 1, 'B' => false, - ) - ); + ], + ]; $this->assertEquals($exp, $data); - $data = array( - 'transition' => array( + $data = [ + 'transition' => [ 'Dur' => 2, 'D' => 3, 'Dm' => 'V', @@ -193,30 +330,30 @@ public function testSanitizeTransitions() 'M' => 'O', 'Di' => 315, 'SS' => 1.3, - 'B' => true - ) - ); - $testObj->sanitizeTransitions($data); - $exp = array( - 'transition' => array( + 'B' => true, + ], + ]; + $page->sanitizeTransitions($data); + $exp = [ + 'transition' => [ 'Dur' => 2, 'D' => 3, 'S' => 'Glitter', 'Di' => 315, 'SS' => 1.3, 'B' => true, - ) - ); + ], + ]; $this->assertEquals($exp, $data); } - public function testSanitizeMargins() + public function testSanitizeMargins(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeMargins($data); - $exp = array( - 'margin' => array( + $page = $this->getTestObject(); + $data = []; + $page->sanitizeMargins($data); + $exp = [ + 'margin' => [ 'PL' => 0, 'PR' => 0, 'PT' => 0, @@ -225,7 +362,7 @@ public function testSanitizeMargins() 'CB' => 0, 'FT' => 0, 'PB' => 0, - ), + ], 'orientation' => 'P', 'height' => 297, 'width' => 210, @@ -233,11 +370,11 @@ public function testSanitizeMargins() 'ContentHeight' => 297, 'HeaderHeight' => 0, 'FooterHeight' => 0, - ); + ]; $this->bcAssertEqualsWithDelta($exp, $data); - $data = array( - 'margin' => array( + $data = [ + 'margin' => [ 'PL' => 11, 'PR' => 12, 'PT' => 13, @@ -246,14 +383,14 @@ public function testSanitizeMargins() 'CB' => 15, 'FT' => 13, 'PB' => 11, - ), + ], 'orientation' => 'P', 'height' => 297, 'width' => 210, - ); - $testObj->sanitizeMargins($data); - $exp = array( - 'margin' => array( + ]; + $page->sanitizeMargins($data); + $exp = [ + 'margin' => [ 'PL' => 11, 'PR' => 12, 'PT' => 13, @@ -262,7 +399,7 @@ public function testSanitizeMargins() 'CB' => 15, 'FT' => 13, 'PB' => 11, - ), + ], 'orientation' => 'P', 'height' => 297, 'width' => 210, @@ -270,334 +407,360 @@ public function testSanitizeMargins() 'ContentHeight' => 267, 'HeaderHeight' => 1, 'FooterHeight' => 2, - ); + ]; $this->bcAssertEqualsWithDelta($exp, $data); } - public function testSanitizeBoxData() + public function testSanitizeBoxData(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizeBoxData($data); - $exp = array( + $page = $this->getTestObject(); + $data = []; + $page->sanitizeBoxData($data); + $exp = [ 'orientation' => 'P', 'pheight' => 841.890, 'pwidth' => 595.276, - 'box' => array( - 'MediaBox' => array( + 'box' => [ + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ), - ), - ), - 'CropBox' => array( + ], + ], + ], + 'CropBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ), - ), - ), - 'BleedBox' => array( + ], + ], + ], + 'BleedBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ), - ), - ), - 'TrimBox' => array( + ], + ], + ], + 'TrimBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ), - ), - ), - 'ArtBox' => array( + ], + ], + ], + 'ArtBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ), - ), - ), - ) - ); + ], + ], + ], + ], + ]; $this->bcAssertEqualsWithDelta($exp, $data); - $data = array( + $data = [ 'format' => 'MediaBox', 'orientation' => 'L', - 'box' => array( - 'MediaBox' => array( + 'box' => [ + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ) - ) - ) - ) - ); - $testObj->sanitizeBoxData($data); - $exp = array( + ], + ], + ], + ], + ]; + $page->sanitizeBoxData($data); + $exp = [ 'format' => 'CUSTOM', 'orientation' => 'L', - 'box' => array( - 'MediaBox' => array( + 'box' => [ + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 841.890, 'ury' => 595.276, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'CropBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'CropBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 841.890, 'ury' => 595.276, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'BleedBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'BleedBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 841.890, 'ury' => 595.276, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'TrimBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'TrimBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 841.890, 'ury' => 595.276, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'ArtBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'ArtBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 841.890, 'ury' => 595.276, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - ), + 'dash' => [ + 0 => 3, + ], + ], + ], + ], 'width' => 297, 'height' => 210, 'pwidth' => 841.890, 'pheight' => 595.276, - ); + ]; $this->bcAssertEqualsWithDelta($exp, $data); - $data = array( + $data = [ 'width' => 210, 'height' => 297, 'pwidth' => 595.276, 'pheight' => 841.890, - 'box' => array( - 'CropBox' => array( + 'box' => [ + 'CropBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ) - ) - ) - ) - ); - $testObj->sanitizeBoxData($data); - $exp = array( + ], + ], + ], + ], + ]; + $page->sanitizeBoxData($data); + $exp = [ 'width' => 210, 'height' => 297, 'pwidth' => 595.276, 'pheight' => 841.890, - 'box' => array( - 'CropBox' => array( + 'box' => [ + 'CropBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'MediaBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'BleedBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'BleedBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'TrimBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'TrimBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - 'ArtBox' => array( + 'dash' => [ + 0 => 3, + ], + ], + ], + 'ArtBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3) - ) - ), - ), + 'dash' => [ + 0 => 3, + ], + ], + ], + ], 'orientation' => 'P', - ); + ]; $this->bcAssertEqualsWithDelta($exp, $data); } - public function testSanitizePageFormat() + public function testSanitizePageFormat(): void { - $testObj = $this->getTestObject(); - $data = array(); - $testObj->sanitizePageFormat($data); - $exp = array( + $page = $this->getTestObject(); + $data = []; + $page->sanitizePageFormat($data); + $exp = [ 'orientation' => 'P', 'format' => 'A4', 'pheight' => 841.890, 'pwidth' => 595.276, 'width' => 210, 'height' => 297, - ); + ]; $this->bcAssertEqualsWithDelta($exp, $data); - $data = array( - 'box' => array( - 'MediaBox' => array( + $data = [ + 'box' => [ + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array( + 'dash' => [ 0 => 3, - ) - ) - ) - ) - ); - $testObj->sanitizePageFormat($data); - $exp = array( - 'box' => array( - 'MediaBox' => array( + ], + ], + ], + ], + ]; + $page->sanitizePageFormat($data); + $exp = [ + 'box' => [ + 'MediaBox' => [ 'llx' => 0, 'lly' => 0, 'urx' => 595.276, 'ury' => 841.890, - 'bci' => array( + 'bci' => [ 'color' => '#000000', 'width' => 0.353, 'style' => 'S', - 'dash' => array(0 => 3), - ), - ), - ), - 'orientation' => '', - 'format' => 'MediaBox', - ); + 'dash' => [ + 0 => 3, + ], + ], + ], + ], + 'orientation' => 'P', + 'format' => 'A4', + 'pwidth' => 595.276, + 'pheight' => 841.890, + 'width' => 210.000, + 'height' => 297.000, + ]; $this->bcAssertEqualsWithDelta($exp, $data); } } diff --git a/test/TestUtil.php b/test/TestUtil.php index a54a780..6c6a3fe 100644 --- a/test/TestUtil.php +++ b/test/TestUtil.php @@ -3,13 +3,13 @@ /** * TestUtil.php * - * @since 2020-12-19 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2020-12-19 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-color software library. */ @@ -21,43 +21,35 @@ /** * Web Color class test * - * @since 2020-12-19 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2020-12-19 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2015-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class TestUtil extends TestCase { - public function bcAssertEqualsWithDelta($expected, $actual, $delta = 0.01, $message = '') - { - if (\is_callable([self::class, 'assertEqualsWithDelta'])) { - parent::assertEqualsWithDelta($expected, $actual, $delta, $message); - return; - } - /* @phpstan-ignore-next-line */ - $this->assertEquals($expected, $actual, $message, $delta); + public function bcAssertEqualsWithDelta( + mixed $expected, + mixed $actual, + float $delta = 0.01, + string $message = '' + ): void { + parent::assertEqualsWithDelta($expected, $actual, $delta, $message); } - public function bcExpectException($exception) + /** + * @param class-string<\Throwable> $exception + */ + public function bcExpectException($exception): void { - if (\is_callable([self::class, 'expectException'])) { - parent::expectException($exception); - return; - } - /* @phpstan-ignore-next-line */ - parent::setExpectedException($exception); + parent::expectException($exception); } - public function bcAssertStringContainsString($needle, $haystack) + public function bcAssertStringContainsString(string $needle, string $haystack): void { - if (\is_callable([self::class, 'assertStringContainsString'])) { - parent::assertStringContainsString($needle, $haystack); - return; - } - /* @phpstan-ignore-next-line */ - parent::assertContains($needle, $haystack); + parent::assertStringContainsString($needle, $haystack); } } diff --git a/test/UnitTest.php b/test/UnitTest.php index 116ee9c..6183e87 100644 --- a/test/UnitTest.php +++ b/test/UnitTest.php @@ -3,55 +3,53 @@ /** * UnitTest.php * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page * * This file is part of tc-lib-pdf-page software library. */ namespace Test; -use PHPUnit\Framework\TestCase; - /** * Unit Test * - * @since 2011-05-23 - * @category Library - * @package PdfPage - * @author Nicola Asuni - * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD - * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) - * @link https://github.com/tecnickcom/tc-lib-pdf-page + * @since 2011-05-23 + * @category Library + * @package PdfPage + * @author Nicola Asuni + * @copyright 2011-2023 Nicola Asuni - Tecnick.com LTD + * @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) + * @link https://github.com/tecnickcom/tc-lib-pdf-page */ class UnitTest extends TestUtil { - protected function getTestObject() + protected function getTestObject(): \Com\Tecnick\Pdf\Page\Page { - $col = new \Com\Tecnick\Color\Pdf(); - $enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); - return new \Com\Tecnick\Pdf\Page\Page('mm', $col, $enc, false, false); + $pdf = new \Com\Tecnick\Color\Pdf(); + $encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false); + return new \Com\Tecnick\Pdf\Page\Page('mm', $pdf, $encrypt, false, false); } - public function testGetPageSize() + public function testGetPageSize(): void { - $testObj = $this->getTestObject(); - $val = $testObj->convertPoints(72, 'in', 3); + $page = $this->getTestObject(); + $val = $page->convertPoints(72, 'in', 3); $this->assertEquals(1, $val); - $val = $testObj->convertPoints(72, 'mm', 3); + $val = $page->convertPoints(72, 'mm', 3); $this->assertEquals(25.4, $val); } - public function testGetPageSizeEx() + public function testGetPageSizeEx(): void { - $this->bcExpectException('\Com\Tecnick\Pdf\Page\Exception'); - $testObj = $this->getTestObject(); - $testObj->convertPoints(1, '*ERROR*', 2); + $this->bcExpectException('\\' . \Com\Tecnick\Pdf\Page\Exception::class); + $page = $this->getTestObject(); + $page->convertPoints(1, '*ERROR*', 2); } }