Class Page

    • Method Detail

      • create

        public static Page create​(Document targetDocument,
                                  Size size)

        Create an empty page

        The page is associated with the given target document but not yet part of it. It can be appended to the document's page list.
        Parameters:
        targetDocument - the output document with which the returned object is associated
        size - the page size
        Returns:
        the newly created page object
        Throws:
        java.lang.IllegalArgumentException - if the targetDocument argument has already been closed
        java.lang.IllegalArgumentException - if the targetDocument argument is read-only
        java.lang.IllegalArgumentException - if targetDocument is null
        java.lang.IllegalArgumentException - if size is null
      • updateSize

        public void updateSize​(Rectangle rectangle)

        Update the page size to a specified rectangle.

        Note that all page-related coordinates are normalized to the crop box of the page. Updating the page size thus changes the coordinate system, rendering all previously extracted coordinates invalid.
        Parameters:
        rectangle - the rectangle to update the page size to.
        Throws:
        java.lang.IllegalStateException - if the owning document has already been closed
        java.lang.IllegalStateException - if the page has already been closed
        java.lang.UnsupportedOperationException - if the page is read-only
        java.lang.IllegalArgumentException - if rectangle is null
      • rotate

        public void rotate​(Rotation rotate)

        Rotate the page by a multiple of 90 degrees.

        Parameters:
        rotate - the desired rotation
        Throws:
        java.lang.IllegalStateException - if the owning document has already been closed
        java.lang.IllegalStateException - if the page has already been closed
        java.lang.UnsupportedOperationException - if the page is read-only
        java.lang.IllegalArgumentException - if rotate is null
      • getSize

        public Size getSize()

        the visible size of the page (crop box). (Getter)

        The page size corresponds to the size of the crop box. Since all coordinates are normalized to the origin of the crop box, the normalized origin of the crop box is always (0,0) and thus only the size is required.

        The crop box defines the region to which the contents of the page shall be clipped (cropped) when displayed or printed. Unlike the other boxes, the crop box has no defined meaning in terms of physical page geometry or intended use; it merely imposes clipping on the page contents. However, in the absence of additional information (such as imposition instructions specified in a JDF job ticket), the crop box determines how the page's contents shall be positioned on the output medium. The default value is the page's media box.

        This property cannot be null.

        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getMediaBox

        public Rectangle getMediaBox()

        The media box of the page. (Getter)

        The media box defines the boundaries of the physical medium on which the page is to be printed. It may include any extended area surrounding the finished page for bleed, printing marks, or other such purposes. It may also include areas close to the edges of the medium that cannot be marked because of physical limitations of the output device. Content falling outside this boundary may safely be discarded without affecting the meaning of the PDF file.

        This property cannot be null.

        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getBleedBox

        public Rectangle getBleedBox()

        The bleed box of the page. (Getter)

        The bleed box (PDF 1.3) defines the region to which the contents of the page shall be clipped when output in a production environment. This may include any extra bleed area needed to accommodate the physical limitations of cutting, folding, and trimming equipment. The actual printed page may include printing marks that fall outside the bleed box. The default value is the page's crop box.

        This property is null if the page contains no explicit bleed box.

        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getTrimBox

        public Rectangle getTrimBox()

        The trim box of the page. (Getter)

        The trim box (PDF 1.3) defines the intended dimensions of the finished page after trimming. It may be smaller than the media box to allow for production-related content, such as printing instructions, cut marks, or colour bars. The default value is the page's crop box.

        This property is null if the page contains no explicit trim box.

        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getArtBox

        public Rectangle getArtBox()

        The art box of the page. (Getter)

        The art box (PDF 1.3) defines the extent of the page's meaningful content (including potential white-space) as intended by the page’s creator. The default value is the page's crop box.

        This property is null if the page contains no explicit art box.

        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getContent

        public Content getContent()

        the page content. (Getter)

        If the page is writable, the content object can be used to apply new content on the page, for example overlays or underlays.
        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getAnnotations

        public AnnotationList getAnnotations()

        the list of this page's annotations. (Getter)

        Adding to this list results in an error:
        • IllegalState if the list has already been closed
        • UnsupportedOperation if the document is read-only
        • IllegalArgument
          • if the given annotation is null
          • if the given annotation object has already been closed
          • if the given annotation does not belong to the same document as the list
          • if the given annotation is already associated with a page
        This list does not support removing or setting elements or clearing.
        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getLinks

        public LinkList getLinks()

        the list of this page's links. (Getter)

        Adding to this list results in an error:
        • IllegalState if the list has already been closed
        • UnsupportedOperation if the document is read-only
        • IllegalArgument
          • if the given link is null
          • if the given link object has already been closed
          • if the given link does not belong to the same document as the list
          • if the given link is already associated with a page
        This list does not support removing or setting elements or clearing.
        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getWidgets

        public WidgetList getWidgets()

        the list of this page's form field widgets. (Getter)

        Adding to this list results in an error:
        • IllegalState if the list has already been closed
        • UnsupportedOperation if the document is read-only
        • IllegalArgument
          • if the given widget is null
          • if the given widget object has already been closed
          • if the given widget does not belong to the same document as the list
          • if the given widget is already associated with a page
        This list does not support removing or setting elements or clearing.
        Throws:
        java.lang.IllegalStateException - if the page has already been closed
      • getMetadata

        public Metadata getMetadata()

        the metadata of the page. (Getter)

        If the document is writable, the metadata object will be writable too and all changes to the metadata object are reflected in the document.

        This property is null if the page has not metadata.

        Throws:
        java.lang.IllegalStateException - if the document has already been closed
      • setMetadata

        public void setMetadata​(Metadata value)

        the metadata of the page. (Setter)

        If the document is writable, the metadata object will be writable too and all changes to the metadata object are reflected in the document.

        This property is null if the page has not metadata.

        Throws:
        java.lang.IllegalStateException - if the document has already been closed
        java.lang.UnsupportedOperationException - if the document is read-only
        java.lang.IllegalArgumentException - if the given Metadata object belongs to a different document
        java.lang.IllegalArgumentException - if the given Metadata object has already been closed