Package org.jfree.pdf

Class Page


public class Page extends PDFObject
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).
  • Field Details

    • parent

      private Pages parent
      The pages of the document.
    • bounds

      private Rectangle2D bounds
      The page bounds.
    • contents

      private GraphicsStream contents
      The page contents.
    • graphics2d

      private PDFGraphics2D graphics2d
      The Graphics2D for writing to the page contents.
    • fontsOnPage

      private List<String> fontsOnPage
      The list of font (names) used on the page. We let the parent take care of tracking the font objects.
    • gradientPaintsOnPage

      private Map<GradientPaintKey,String> gradientPaintsOnPage
      A map between gradient paints and the names used to define the associated pattern in the page resources.
    • radialGradientPaintsOnPage

      private Map<RadialGradientPaintKey,String> radialGradientPaintsOnPage
    • patterns

      private Dictionary patterns
      The pattern dictionary for this page.
    • graphicsStates

      private Dictionary graphicsStates
      The ExtGState dictionary for the page.
    • j2DTransform

      private AffineTransform j2DTransform
      The transform between Page and Java2D coordinates, used in Shading patterns.
    • xObjects

      private Dictionary xObjects
    • alphaDictionaries

      private Map<Integer,String> alphaDictionaries
  • Constructor Details

    • Page

      Page(int number, int generation, Pages parent, Rectangle2D bounds)
      Creates a new page.
      Parameters:
      number - the PDF object number.
      generation - the PDF object generation number.
      parent - the parent (manages the pages in the PDFDocument).
      bounds - the page bounds (null not permitted).
    • Page

      Page(int number, int generation, Pages parent, Rectangle2D bounds, boolean filter)
      Creates a new page.
      Parameters:
      number - the PDF object number.
      generation - the PDF object generation number.
      parent - the parent (manages the pages in the PDFDocument).
      bounds - the page bounds (null not permitted).
      filter - a flag that controls whether or not the graphics stream for the page has a FlateFilter applied.
      Since:
      1.4
  • 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 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.
    • createFontDictionary

      private Dictionary createFontDictionary()
    • 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.
    • createFunctionForMultipleGradient

      private Function createFunctionForMultipleGradient(MultipleGradientPaint mgp)
    • 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.
    • addSoftMaskImage

      String addSoftMaskImage(Image img)
      Adds a soft mask image to the page. This is called from the
      invalid reference
      #addImage(java.awt.Image)
      method to support image transparency.
      Parameters:
      img - the image (null not permitted).
      Returns:
      The soft mask image 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()
      Description copied from class: PDFObject
      Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
      Specified by:
      getObjectBytes in class PDFObject
      Returns:
      A byte array.
    • createDictionary

      private Dictionary createDictionary()