PageBoundaries.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * This file is part of FPDI
  4. *
  5. * @package Fpdi
  6. * @copyright Copyright (c) 2020 Setasign GmbH & Co. KG (https://www.setasign.com)
  7. * @license http://opensource.org/licenses/mit-license The MIT License
  8. */
  9. namespace Fpdi\PdfReader;
  10. /**
  11. * An abstract class for page boundary constants and some helper methods
  12. */
  13. abstract class PageBoundaries
  14. {
  15. /**
  16. * MediaBox
  17. *
  18. * The media box defines the boundaries of the physical medium on which the page is to be printed.
  19. *
  20. * @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
  21. * @var string
  22. */
  23. const MEDIA_BOX = 'MediaBox';
  24. /**
  25. * CropBox
  26. *
  27. * The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or
  28. * printed.
  29. *
  30. * @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
  31. * @var string
  32. */
  33. const CROP_BOX = 'CropBox';
  34. /**
  35. * BleedBox
  36. *
  37. * The bleed box defines the region to which the contents of the page shall be clipped when output in a
  38. * production environment.
  39. *
  40. * @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
  41. * @var string
  42. */
  43. const BLEED_BOX = 'BleedBox';
  44. /**
  45. * TrimBox
  46. *
  47. * The trim box defines the intended dimensions of the finished page after trimming.
  48. *
  49. * @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
  50. * @var string
  51. */
  52. const TRIM_BOX = 'TrimBox';
  53. /**
  54. * ArtBox
  55. *
  56. * The art box defines the extent of the page’s meaningful content (including potential white space) as intended
  57. * by the page’s creator.
  58. *
  59. * @see PDF 32000-1:2008 - 14.11.2 Page Boundaries
  60. * @var string
  61. */
  62. const ART_BOX = 'ArtBox';
  63. /**
  64. * All page boundaries
  65. *
  66. * @var array
  67. */
  68. public static $all = array(
  69. self::MEDIA_BOX,
  70. self::CROP_BOX,
  71. self::BLEED_BOX,
  72. self::TRIM_BOX,
  73. self::ART_BOX
  74. );
  75. /**
  76. * Checks if a name is a valid page boundary name.
  77. *
  78. * @param string $name The boundary name
  79. * @return boolean A boolean value whether the name is valid or not.
  80. */
  81. public static function isValidName($name)
  82. {
  83. return \in_array($name, self::$all, true);
  84. }
  85. }