public class PDFPage extends PDFObject implements Serializable
This class defines a single page within a document. It is linked to a single PDFGraphics object
Modifier and Type | Class and Description |
---|---|
class |
PDFPage.procset
This defines a procset
|
Constructor and 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(PDFPageFormat pageFormat)
Constructs a page using the supplied media size and orientation.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PDFObject ob)
This adds an object that describes some content to this page.
|
void |
addAnnotation(PDFObject ob)
This adds an Annotation to the page.
|
void |
addImageResource(PDFImage object)
This adds an image resource to the page.
|
PDFAnnot |
addLink(int x,
int y,
int w,
int h,
PDFObject dest)
Adds a hyperlink to the document.
|
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.
|
PDFAnnot |
addNote(String note,
int x,
int y,
int w,
int h)
This method adds a text note to the document.
|
PDFOutline |
addOutline(String title)
This method attaches an outline to the current page being generated.
|
PDFOutline |
addOutline(String title,
int x,
int y,
int w,
int h)
This method attaches an outline to the current page being generated.
|
void |
addPatternResource(PDFPattern object)
This adds a pattern resource to the page.
|
void |
addShadingResource(PDFShading object)
This adds a shading resource to the page.
|
void |
addToProcset(String proc)
Adds to procset.
|
int |
cx(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.
|
int |
cy(int x,
int y)
This utility method converts the y coordinate from Java to User space within the page.
|
PDFCanvas |
getCanvas()
This returns a PDFGraphics object, which can then be used to render on to this page.
|
PDFFont |
getFont(String type,
Typeface typeface)
Returns a PDFFont, creating it if not yet used.
|
Rect |
getImageableArea()
Gets the imageable area of the page.
|
int |
getOrientation()
Returns the pages orientation: PageFormat.PORTRAIT, PageFormat.LANDSACPE or PageFromat.REVERSE_LANDSACPE
|
PDFPageFormat |
getPageFormat()
Returns the page's PageFormat.
|
void |
setOrientation(int orientation)
Sets the page's orientation.
|
void |
setThumbnail(PDFObject thumbnail)
This adds an object that describes a thumbnail for this page.
|
void |
write(OutputStream os)
Writes the object to the output stream.
|
getGeneration, getName, getPDFDocument, getSerialID, getType, setName, toArray, toString, writeEnd, writeStart
public PDFPage()
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.
public PDFPage(int orientation)
orientation
- Orientation: 0, 90 or 270PDFPageFormat.PORTRAIT
,
PDFPageFormat.LANDSCAPE
,
PDFPageFormat#REVERSE_LANDSCAPE
public PDFPage(PDFPageFormat pageFormat)
pageFormat
- PageFormat describing the page sizepublic void addToProcset(String proc)
proc
- the String to be added.public PDFCanvas getCanvas()
public PDFFont getFont(String type, Typeface typeface)
type
- Font type, usually /Type1font
- Font namestyle
- java.awt.Font style, ie Font.NORMALpublic PDFPageFormat getPageFormat()
public Rect getImageableArea()
public void setOrientation(int orientation)
Normally, this should be done when the page is created, to avoid problems.
orientation
- a PageFormat orientation constant: PageFormat.PORTRAIT, PageFormat.LANDSACPE or
PageFromat.REVERSE_LANDSACPEpublic int getOrientation()
java.awt.PDFPageFormat.PageFormat
public void add(PDFObject ob)
Note: Objects that describe contents must be added using this method _AFTER_ the PDF.add() method has been called.
ob
- PDFObject describing some contentspublic void addAnnotation(PDFObject ob)
As with other objects, the annotation must be added to the pdf document using PDF.add() before adding to the page.
ob
- Annotation to add.public PDFAnnot addNote(String note, int x, int y, int w, int h)
note
- Text of the notex
- Coordinate of notey
- Coordinate of notew
- Width of the noteh
- Height of the notepublic PDFAnnot addLink(int x, int y, int w, int h, PDFObject dest)
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.public PDFAnnot addLink(int x, int y, int w, int h, PDFObject dest, int vx, int vy, int vw, int vh)
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 areapublic void addImageResource(PDFImage object)
resourceName
- the XObject resource to be added.public void addPatternResource(PDFPattern object)
resourceName
- the XObject resource to be added.public void addShadingResource(PDFShading object)
resourceName
- the XObject resource to be added.public void setThumbnail(PDFObject thumbnail)
Note: The object must already exist in the PDF, as only the object ID is stored.
thumbnail
- PDFObject containing the thumbnailpublic PDFOutline addOutline(String title)
title
- Outline title to attachpublic PDFOutline addOutline(String title, int x, int y, int w, int h)
Note: If the outline is not in the top level (ie below another outline) then it must not be passed to this method.
title
- Outline title to attachx
- Left coordinate of regiony
- Bottom coordinate of regionw
- Width of regionh
- Height coordinate of regionpublic void write(OutputStream os) throws IOException
PDFObject
Writes 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.
write
in class PDFObject
os
- OutputStream to send the object toIOException
- on errorpublic int cy(int x, int y)
x
- Coordinate in Java spacey
- Coordinate in Java spacepublic int cx(int x, int y)
x
- Coordinate in Java spacey
- Coordinate in Java spacepublic int[] cxy(int x, int y)
x
- Coordinate in Java spacey
- Coordinate in Java space