java.lang.Object
org.jfree.pdf.internal.PDFObject
org.jfree.pdf.Page
public class Page extends org.jfree.pdf.internal.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).-
Method Summary
Modifier and Type Method Description StringaddImage(Image img, boolean addSoftMaskImage)Adds an image to the page.This creates the required PDF object, as well as adding a reference in thexObjectsresources.StringfindOrCreateFontReference(Font font)Finds the font reference corresponding to the given Java2D font, creating a new one if there isn't one already.StringfindOrCreateGSDictionary(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.StringfindOrCreatePattern(GradientPaint gp)Returns the name of the pattern for the specifiedGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.StringfindOrCreatePattern(RadialGradientPaint gp)Returns the name of the pattern for the specifiedRadialGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.Rectangle2DgetBounds()Returns a new rectangle containing the bounds for this page (as supplied to the constructor).org.jfree.pdf.internal.PDFObjectgetContents()Returns thePDFObjectthat represents the page content.PDFGraphics2DgetGraphics2D()Returns thePDFGraphics2Dinstance for drawing to the page.byte[]getObjectBytes()Returns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.
-
Method Details
-
getBounds
Returns a new rectangle containing the bounds for this page (as supplied to the constructor).- Returns:
- The page bounds.
-
getContents
Returns thePDFObjectthat represents the page content.- Returns:
- The
PDFObjectthat represents the page content.
-
getGraphics2D
Returns thePDFGraphics2Dinstance for drawing to the page.- Returns:
- The
PDFGraphics2Dinstance for drawing to the page.
-
findOrCreateFontReference
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
Returns the name of the pattern for the specifiedGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.- Parameters:
gp- the gradient (nullnot permitted).- Returns:
- The pattern name.
-
findOrCreatePattern
Returns the name of the pattern for the specifiedRadialGradientPaint, reusing an existing pattern if possible, otherwise creating a new pattern if necessary.- Parameters:
gp- the gradient (nullnot permitted).- Returns:
- The pattern name.
-
findOrCreateGSDictionary
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
Adds an image to the page.This creates the required PDF object, as well as adding a reference in thexObjectsresources. You should not call this method directly, it exists for the use of thePDFGraphics2D.drawImage(java.awt.Image, int, int, int, int, java.awt.image.ImageObserver)method.- Parameters:
img- the image (nullnot permitted).addSoftMaskImage- add as a soft mask image?- Returns:
- The image reference name.
-
getObjectBytes
Description copied from class:org.jfree.pdf.internal.PDFObjectReturns the bytes that go between the 'obj' and 'endobj' in the PDF output for this object.- Specified by:
getObjectBytesin classorg.jfree.pdf.internal.PDFObject- Returns:
- A byte array.
-