Class PDFPage
- java.lang.Object
-
- pdf.PDFObject
-
- pdf.PDFPage
-
- All Implemented Interfaces:
java.io.Serializable
public class PDFPage extends PDFObject implements java.io.Serializable
This class defines a single page within a document. It is linked to a single PDFGraphics object
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPDFPage.procsetThis defines a procset
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Vector<PDFObject>annotationsThis holds any Annotations contained within this page.protected java.util.Vector<PDFObject>contentsThis holds the contents of the page.protected java.util.Vector<PDFFont>fontsThe fonts associated with this pageprotected booleanhasImageBThese handle the procset for this page.protected booleanhasImageCThese handle the procset for this page.protected booleanhasImageIThese handle the procset for this page.protected java.util.Vector<java.lang.String>imageResourcesprotected java.awt.print.PageFormatpageFormatThis is this page format, ie the size of the page, margins, and rotationprotected PDFObjectpdfPageListThis is the pages object id that this page belongs to.protected PDFPage.procsetprocsetprotected java.util.Vector<java.lang.String>resourcesThis holds any resources for this pageprotected PDFObjectthumbnailObject ID that contains a thumbnail sketch of the page-
Fields inherited from class pdf.PDFObject
objser, pdfDocument
-
-
Constructor Summary
Constructors Constructor Description PDFPage()This constructs a Page object, which will hold any contents for this page.PDFPage(int orientation)Constructs a page using A4 media, but using the supplied orientation.PDFPage(java.awt.print.PageFormat pageFormat)Constructs a page using the supplied media size and orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(PDFObject ob)This adds an object that describes some content to this page.voidaddAnnotation(PDFObject ob)This adds an Annotation to the page.voidaddImageResource(java.lang.String resource)This adds an image resource to the page.PDFAnnotaddLink(int x, int y, int w, int h, PDFObject dest)Adds a hyperlink to the document.PDFAnnotaddLink(int x, int y, int w, int h, PDFObject dest, int vx, int vy, int vw, int vh)Adds a hyperlink to the document.PDFAnnotaddNote(java.lang.String note, int x, int y, int w, int h)This method adds a text note to the document.PDFOutlineaddOutline(java.lang.String title)This method attaches an outline to the current page being generated.PDFOutlineaddOutline(java.lang.String title, int x, int y, int w, int h)This method attaches an outline to the current page being generated.voidaddResource(java.lang.String resource)This adds a resource to the page.voidaddToProcset(java.lang.String proc)Adds to procset.voidaddXObject(java.lang.String inxobject)This adds an XObject resource to the page.intcx(int x, int y)This utility method converts the y coordinate from Java to User space within the page.int[]cxy(int x, int y)This utility method converts the Java coordinates to User space within the page.intcy(int x, int y)This utility method converts the y coordinate from Java to User space within the page.java.awt.DimensiongetDimension()Gets the dimensions of the page.PDFFontgetFont(java.lang.String type, java.lang.String font, int style)Returns a PDFFont, creating it if not yet used.PDFGraphicsgetGraphics()This returns a PDFGraphics object, which can then be used to render on to this page.java.awt.RectanglegetImageableArea()Gets the imageable area of the page.intgetOrientation()Returns the pages orientation: PageFormat.PORTRAIT, PageFormat.LANDSACPE or PageFromat.REVERSE_LANDSACPEjava.awt.print.PageFormatgetPageFormat()Returns the page's PageFormat.voidsetOrientation(int orientation)Sets the page's orientation.voidsetThumbnail(PDFObject thumbnail)This adds an object that describes a thumbnail for this page.voidwrite(java.io.OutputStream os)Writes the object to the output stream.-
Methods inherited from class pdf.PDFObject
getPDFDocument, getSerialID, getType, toArray, toString, writeEnd, writeStart
-
-
-
-
Field Detail
-
pageFormat
protected java.awt.print.PageFormat pageFormat
This is this page format, ie the size of the page, margins, and rotation
-
pdfPageList
protected PDFObject pdfPageList
This is the pages object id that this page belongs to. It is set by the pages object when it is added to it.
-
contents
protected java.util.Vector<PDFObject> contents
This holds the contents of the page.
-
thumbnail
protected PDFObject thumbnail
Object ID that contains a thumbnail sketch of the page. -1 indicates no thumbnail.
-
annotations
protected java.util.Vector<PDFObject> annotations
This holds any Annotations contained within this page.
-
resources
protected java.util.Vector<java.lang.String> resources
This holds any resources for this page
-
imageResources
protected java.util.Vector<java.lang.String> imageResources
-
fonts
protected java.util.Vector<PDFFont> fonts
The fonts associated with this page
-
hasImageB
protected boolean hasImageB
These handle the procset for this page. Refer to page 140 of the PDF Reference manual NB: Text is handled when the fonts Vector is null, and a font is created refer to getFont() to see where it's defined
-
hasImageC
protected boolean hasImageC
These handle the procset for this page. Refer to page 140 of the PDF Reference manual NB: Text is handled when the fonts Vector is null, and a font is created refer to getFont() to see where it's defined
-
hasImageI
protected boolean hasImageI
These handle the procset for this page. Refer to page 140 of the PDF Reference manual NB: Text is handled when the fonts Vector is null, and a font is created refer to getFont() to see where it's defined
-
procset
protected PDFPage.procset procset
-
-
Constructor Detail
-
PDFPage
public PDFPage()
This constructs a Page object, which will hold any contents for this page.Once created, it is added to the document via the PDF.add() method. (For Advanced use, via the PDFPages.add() method).
This defaults to a4 media.
-
PDFPage
public PDFPage(int orientation)
Constructs a page using A4 media, but using the supplied orientation.- Parameters:
orientation- Orientation: 0, 90 or 270- See Also:
PageFormat.PORTRAIT,PageFormat.LANDSCAPE,PageFormat.REVERSE_LANDSCAPE
-
PDFPage
public PDFPage(java.awt.print.PageFormat pageFormat)
Constructs a page using the supplied media size and orientation.- Parameters:
pageFormat- PageFormat describing the page size
-
-
Method Detail
-
addToProcset
public void addToProcset(java.lang.String proc)
Adds to procset.- Parameters:
proc- the String to be added.
-
getGraphics
public PDFGraphics getGraphics()
This returns a PDFGraphics object, which can then be used to render on to this page. If a previous PDFGraphics object was used, this object is appended to the page, and will be drawn over the top of any previous objects.- Returns:
- a new PDFGraphics object to be used to draw this page.
-
getFont
public PDFFont getFont(java.lang.String type, java.lang.String font, int style)
Returns a PDFFont, creating it if not yet used.- Parameters:
type- Font type, usually /Type1font- Font namestyle- java.awt.Font style, ie Font.NORMAL- Returns:
- a PDFFont object.
-
getPageFormat
public java.awt.print.PageFormat getPageFormat()
Returns the page's PageFormat.- Returns:
- PageFormat describing the page size in device units (72dpi)
-
getDimension
public java.awt.Dimension getDimension()
Gets the dimensions of the page.- Returns:
- a Dimension object containing the width and height of the page.
-
getImageableArea
public java.awt.Rectangle getImageableArea()
Gets the imageable area of the page.- Returns:
- a Rectangle containing the bounds of the imageable area.
-
setOrientation
public void setOrientation(int orientation)
Sets the page's orientation.Normally, this should be done when the page is created, to avoid problems.
- Parameters:
orientation- a PageFormat orientation constant: PageFormat.PORTRAIT, PageFormat.LANDSACPE or PageFromat.REVERSE_LANDSACPE
-
getOrientation
public int getOrientation()
Returns the pages orientation: PageFormat.PORTRAIT, PageFormat.LANDSACPE or PageFromat.REVERSE_LANDSACPE- Returns:
- current orientation of the page
- See Also:
PageFormat
-
add
public void add(PDFObject ob)
This adds an object that describes some content to this page.Note: Objects that describe contents must be added using this method _AFTER_ the PDF.add() method has been called.
- Parameters:
ob- PDFObject describing some contents
-
addAnnotation
public void addAnnotation(PDFObject ob)
This adds an Annotation to the page.As with other objects, the annotation must be added to the pdf document using PDF.add() before adding to the page.
- Parameters:
ob- Annotation to add.
-
addNote
public PDFAnnot addNote(java.lang.String note, int x, int y, int w, int h)
This method adds a text note to the document.- Parameters:
note- Text of the notex- Coordinate of notey- Coordinate of notew- Width of the noteh- Height of the note- Returns:
- Returns the annotation, so other settings can be changed.
-
addLink
public PDFAnnot addLink(int x, int y, int w, int h, PDFObject dest)
Adds a hyperlink to the document.- Parameters:
x- Coordinate of active areay- Coordinate of active areaw- Width of the active areah- Height of the active areadest- Page that will be displayed when the link is activated. When displayed, the zoom factor will be changed to fit the display.- Returns:
- Returns the annotation, so other settings can be changed.
-
addLink
public PDFAnnot addLink(int x, int y, int w, int h, PDFObject dest, int vx, int vy, int vw, int vh)
Adds a hyperlink to the document.- Parameters:
x- Coordinate of active areay- Coordinate of active areaw- Width of the active areah- Height of the active areadest- Page that will be displayed when the link is activatedvx- Coordinate of view areavy- Coordinate of view areavw- Width of the view areavh- Height of the view area- Returns:
- Returns the annotation, so other settings can be changed.
-
addXObject
public void addXObject(java.lang.String inxobject)
This adds an XObject resource to the page. The string should be of the format /Name ObjectNumber RevisionNumber R as in /Image1 13 0 R .- Parameters:
inxobject- the XObject resource to be added.
-
addResource
public void addResource(java.lang.String resource)
This adds a resource to the page.- Parameters:
resource- String defining the resource
-
addImageResource
public void addImageResource(java.lang.String resource)
This adds an image resource to the page.- Parameters:
resource- the XObject resource to be added.
-
setThumbnail
public void setThumbnail(PDFObject thumbnail)
This adds an object that describes a thumbnail for this page.Note: The object must already exist in the PDF, as only the object ID is stored.
- Parameters:
thumbnail- PDFObject containing the thumbnail
-
addOutline
public PDFOutline addOutline(java.lang.String title)
This method attaches an outline to the current page being generated. When selected, the outline displays the top of the page.- Parameters:
title- Outline title to attach- Returns:
- PDFOutline object created, for addSubOutline if required.
-
addOutline
public PDFOutline addOutline(java.lang.String title, int x, int y, int w, int h)
This method attaches an outline to the current page being generated. When selected, the outline displays the top of the page.Note: If the outline is not in the top level (ie below another outline) then it must not be passed to this method.
- Parameters:
title- Outline title to attachx- Left coordinate of regiony- Bottom coordinate of regionw- Width of regionh- Height coordinate of region- Returns:
- PDFOutline object created, for addSubOutline if required.
-
write
public void write(java.io.OutputStream os) throws java.io.IOExceptionDescription copied from class:PDFObjectWrites the object to the output stream. This method must be overidden.
Note: It should not write any other objects, even if they are it's Kids, as they will be written by the calling routine.
-
cy
public int cy(int x, int y)This utility method converts the y coordinate from Java to User space within the page.- Parameters:
x- Coordinate in Java spacey- Coordinate in Java space- Returns:
- y Coordinate in User space
-
cx
public int cx(int x, int y)This utility method converts the y coordinate from Java to User space within the page.- Parameters:
x- Coordinate in Java spacey- Coordinate in Java space- Returns:
- x Coordinate in User space
-
cxy
public int[] cxy(int x, int y)This utility method converts the Java coordinates to User space within the page.- Parameters:
x- Coordinate in Java spacey- Coordinate in Java space- Returns:
- array containing the x and y Coordinate in User space
-
-