Class PCLPageDefinition


  • public class PCLPageDefinition
    extends java.lang.Object
    This class represents a page format with PCL-specific properties.
    • Field Detail

      • pageDefinitions

        private static java.util.List pageDefinitions
      • name

        private final java.lang.String name
      • selector

        private final int selector
      • physicalPageSize

        private final java.awt.Dimension physicalPageSize
      • logicalPageRect

        private final java.awt.Rectangle logicalPageRect
      • landscape

        private final boolean landscape
    • Constructor Detail

      • PCLPageDefinition

        public PCLPageDefinition​(java.lang.String name,
                                 int selector,
                                 java.awt.Dimension physicalPageSize,
                                 java.awt.Rectangle logicalPageRect,
                                 boolean landscape)
        Main constructor
        Parameters:
        name - the name of the page definition
        selector - the selector used by the <ESC> command (page size)
        physicalPageSize - the physical page size
        logicalPageRect - the rectangle defining the logical page
        landscape - true if it is a landscape format
    • Method Detail

      • getName

        public java.lang.String getName()
        Returns:
        the name of the page definition
      • getSelector

        public int getSelector()
        Returns:
        the selector used by the <ESC> command (page size)
      • isLandscapeFormat

        public boolean isLandscapeFormat()
        Returns:
        true if it is a landscape format
      • getPhysicalPageSize

        public java.awt.Dimension getPhysicalPageSize()
        Returns:
        the physical page size
      • getLogicalPageRect

        public java.awt.Rectangle getLogicalPageRect()
        Returns:
        the rectangle defining the logical page
      • matches

        private boolean matches​(long width,
                                long height,
                                int errorMargin)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getPageDefinition

        public static PCLPageDefinition getPageDefinition​(long width,
                                                          long height,
                                                          int errorMargin)
        Tries to determine a matching page definition.
        Parameters:
        width - the physical page width (in mpt)
        height - the physical page height (in mpt)
        errorMargin - the error margin for detecting the right page definition
        Returns:
        the page definition or null if no match was found
      • getPageDefinition

        public static PCLPageDefinition getPageDefinition​(java.lang.String name)
        Returns a page definition based on a page format.
        Parameters:
        name - the name of the page format (ex. "A4" or "Letter")
        Returns:
        the page definition or null if no match was found
      • getDefaultPageDefinition

        public static PCLPageDefinition getDefaultPageDefinition()
        Returns:
        the default page definition (letter)
      • convert300dpiDotsToMpt

        private static int convert300dpiDotsToMpt​(int offset)
        Converts an offset values for logical pages to millipoints. The values are given as pixels in a 300dpi environment.
        Parameters:
        offset - the offset as given in the PCL 5 specification (under "Printable Area")
        Returns:
        the converted value in millipoints
      • createPhysicalPageSizeInch

        private static java.awt.Dimension createPhysicalPageSizeInch​(float width,
                                                                     float height)
      • createPhysicalPageSizeMm

        private static java.awt.Dimension createPhysicalPageSizeMm​(float width,
                                                                   float height)
      • createLogicalPageRect

        private static java.awt.Rectangle createLogicalPageRect​(int x,
                                                                int y,
                                                                int width,
                                                                int height)
      • createPageDefinitions

        private static void createPageDefinitions()