Class Page

java.lang.Object
org.jfree.pdf.Page

public class Page extends Object
Represents a page in a PDFDocument. Our objective is to be able to write to the page using the PDFGraphics2D class (see the getGraphics2D() method).
  • Method Summary

    Modifier and Type
    Method
    Description
    addImage(Image img, boolean addSoftMaskImage)
    Adds an image to the page.This creates the required PDF object, as well as adding a reference in the xObjects resources.
    Finds the font reference corresponding to the given Java2D font, creating a new one if there isn't one already.
    Returns the name of the Graphics State Dictionary that can be used for the specified alpha value - if there is no existing dictionary then a new one is created.
    Returns the name of the pattern for the specified GradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.
    Returns the name of the pattern for the specified RadialGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.
    Returns a new rectangle containing the bounds for this page (as supplied to the constructor).
    org.jfree.pdf.internal.PDFObject
    Returns the PDFObject that represents the page content.
    int
    Returns the PDF object generation number.
    Returns the PDFGraphics2D instance for drawing to the page.
    int
    Returns the PDF object number (specified in the constructor).
    byte[]
    Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
    Returns the PDF reference string for this object (for example, "2 0 R").
    byte[]
    Returns the PDF bytes representing this object.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBounds

      public Rectangle2D getBounds()
      Returns a new rectangle containing the bounds for this page (as supplied to the constructor).
      Returns:
      The page bounds.
    • getContents

      public org.jfree.pdf.internal.PDFObject getContents()
      Returns the PDFObject that represents the page content.
      Returns:
      The PDFObject that represents the page content.
    • getGraphics2D

      public PDFGraphics2D getGraphics2D()
      Returns the PDFGraphics2D instance for drawing to the page.
      Returns:
      The PDFGraphics2D instance for drawing to the page.
    • findOrCreateFontReference

      public String findOrCreateFontReference(Font font)
      Finds the font reference corresponding to the given Java2D font, creating a new one if there isn't one already.
      Parameters:
      font - the AWT font.
      Returns:
      The font reference.
    • findOrCreatePattern

      public String findOrCreatePattern(GradientPaint gp)
      Returns the name of the pattern for the specified GradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.
      Parameters:
      gp - the gradient (null not permitted).
      Returns:
      The pattern name.
    • findOrCreatePattern

      public String findOrCreatePattern(RadialGradientPaint gp)
      Returns the name of the pattern for the specified RadialGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.
      Parameters:
      gp - the gradient (null not permitted).
      Returns:
      The pattern name.
    • findOrCreateGSDictionary

      public String findOrCreateGSDictionary(int alpha)
      Returns the name of the Graphics State Dictionary that can be used for the specified alpha value - if there is no existing dictionary then a new one is created.
      Parameters:
      alpha - the alpha value in the range 0 to 255.
      Returns:
      The graphics state dictionary reference.
    • addImage

      public String addImage(Image img, boolean addSoftMaskImage)
      Adds an image to the page.This creates the required PDF object, as well as adding a reference in the xObjects resources. You should not call this method directly, it exists for the use of the PDFGraphics2D.drawImage(java.awt.Image, int, int, int, int, java.awt.image.ImageObserver) method.
      Parameters:
      img - the image (null not permitted).
      addSoftMaskImage - add as a soft mask image?
      Returns:
      The image reference name.
    • getObjectBytes

      public byte[] getObjectBytes()
      Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
      Returns:
      A byte array.
    • getNumber

      public int getNumber()
      Returns the PDF object number (specified in the constructor).
      Returns:
      The PDF object number.
    • getGeneration

      public int getGeneration()
      Returns the PDF object generation number.
      Returns:
      The PDF object generation number.
    • getReference

      public String getReference()
      Returns the PDF reference string for this object (for example, "2 0 R"). This is the PDF object number followed by a space followed by the PDF object generation number, followed by a space and an 'R'.
      Returns:
      The PDF reference string.
    • toPDFBytes

      public byte[] toPDFBytes() throws IOException
      Returns the PDF bytes representing this object.
      Returns:
      The PDF bytes representing this object.
      Throws:
      IOException - if there is a problem writing to the byte array.