public class PDFPage
extends java.lang.Object
This file also contains all of the PDFCmd commands that might be a part of the command stream in a PDFPage. They probably should be inner classes of PDFPage instead of separate non-public classes.
Constructor and Description |
---|
PDFPage(int pageNumber,
java.awt.geom.Rectangle2D bbox,
int rotation,
Cache cache)
create a PDFPage
|
PDFPage(java.awt.geom.Rectangle2D bbox,
int rotation)
create a PDFPage with dimensions in bbox and rotation.
|
Modifier and Type | Method and Description |
---|---|
void |
addCommand(PDFCmd cmd)
Add a single command to the page list.
|
void |
addCommands(PDFPage page)
add a collection of commands to the page list.
|
void |
addCommands(PDFPage page,
java.awt.geom.AffineTransform extra)
add a collection of commands to the page list.
|
void |
addDash(float[] dashary,
float phase)
set the dash style
|
void |
addEndCap(int capstyle)
set the end cap style
|
void |
addFillAlpha(float a)
set the fill alpha
|
void |
addFillPaint(PDFPaint p)
set the fill paint
|
void |
addImage(PDFImage image)
draw an image
|
void |
addLineJoin(int joinstyle)
set the line join style
|
void |
addMiterLimit(float limit)
set the miter limit
|
void |
addPath(java.awt.geom.GeneralPath path,
int style)
set the current path
|
void |
addPop()
pop the graphics state
|
void |
addPush()
push the graphics state
|
void |
addStrokeAlpha(float a)
set the stroke alpha
|
void |
addStrokePaint(PDFPaint p)
set the stroke paint
|
void |
addStrokeWidth(float w)
set the stroke width
|
void |
addXform(java.awt.geom.AffineTransform at)
concatenate a transform to the graphics state
|
void |
clearCommands()
Clear all commands off the current page
|
void |
finish()
The entire page is done.
|
float |
getAspectRatio()
get the aspect ratio of the correctly oriented page.
|
java.awt.geom.Rectangle2D |
getBBox()
get the post-rotation box placed at 0, 0 in page units
|
PDFCmd |
getCommand(int index)
get the command at a given index
|
int |
getCommandCount()
get the current number of commands for this page
|
java.util.List<PDFCmd> |
getCommands()
get all the commands in the current page
|
java.util.List |
getCommands(int startIndex)
get all the commands in the current page starting at the given index
|
java.util.List |
getCommands(int startIndex,
int endIndex) |
float |
getHeight()
get the height of this page, in page points, after rotation
|
java.awt.Image |
getImage(int width,
int height,
java.awt.geom.Rectangle2D clip,
java.awt.image.ImageObserver observer)
Get an image producer which can be used to draw the image
represented by this PDFPage.
|
java.awt.Image |
getImage(int width,
int height,
java.awt.geom.Rectangle2D clip,
java.awt.image.ImageObserver observer,
boolean drawbg,
boolean wait)
Get an image producer which can be used to draw the image
represented by this PDFPage.
|
java.awt.geom.AffineTransform |
getInitialTransform(int width,
int height,
java.awt.geom.Rectangle2D clip)
Get the initial transform to map from a specified clip rectangle in
pdf coordinates to an image of the specfied width and
height in device coordinates
|
java.awt.geom.Rectangle2D |
getPageBox()
Get the original crop/media box of the page, in page units, before
any rotation and with clipping co-ordinates
|
int |
getPageNumber()
get the page number used to lookup this page
|
int |
getRotation()
get the rotation of this image
|
java.awt.Dimension |
getUnstretchedSize(int width,
int height,
java.awt.geom.Rectangle2D clip)
Get the width and height of this image in the correct aspect ratio.
|
float |
getWidth()
get the width of this page, in page points, after rotation
|
boolean |
isFinished()
get whether parsing for this PDFPage has been completed and all
commands are in place.
|
void |
stop(int width,
int height,
java.awt.geom.Rectangle2D clip)
Stop the rendering of a particular image on this page
|
void |
updateImages()
Notify all images we know about that a command has been added
|
void |
waitForFinish()
wait for finish
|
public PDFPage(java.awt.geom.Rectangle2D bbox, int rotation)
public PDFPage(int pageNumber, java.awt.geom.Rectangle2D bbox, int rotation, Cache cache)
pageNumber
- the page numberbbox
- the bounding box, specified in pre-rotation page co-ordinatesrotation
- the rotation to apply to the page; must be 0/90/180/270cache
- a cache to usepublic java.awt.Dimension getUnstretchedSize(int width, int height, java.awt.geom.Rectangle2D clip)
width
- the maximum width of the imageheight
- the maximum height of the imageclip
- the region in page space co-ordinates of the page to
display. It may be null, in which the page crop/media box is used.public java.awt.Image getImage(int width, int height, java.awt.geom.Rectangle2D clip, java.awt.image.ImageObserver observer)
width
- the width of the image to be producedheight
- the height of the image to be producedclip
- the region in page space of the entire page to
displayobserver
- an image observer who will be notified when the
image changes, or nullpublic java.awt.Image getImage(int width, int height, java.awt.geom.Rectangle2D clip, java.awt.image.ImageObserver observer, boolean drawbg, boolean wait)
width
- the width of the image to be producedheight
- the height of the image to be producedclip
- the region in page space of the entire page to
displayobserver
- an image observer who will be notified when the
image changes, or nulldrawbg
- if true, put a white background on the image. If not,
draw no color (alpha 0) for the background.wait
- if true, do not return until this image is fully rendered.public int getPageNumber()
public float getAspectRatio()
public java.awt.geom.Rectangle2D getPageBox()
public java.awt.geom.Rectangle2D getBBox()
public float getWidth()
public float getHeight()
public int getRotation()
public java.awt.geom.AffineTransform getInitialTransform(int width, int height, java.awt.geom.Rectangle2D clip)
width
- the width of the target imageheight
- the height of the target imageclip
- the desired clip rectangle to use in page co-ordinates;
use null
to draw the page crop/media boxpublic int getCommandCount()
public PDFCmd getCommand(int index)
public java.util.List<PDFCmd> getCommands()
public java.util.List getCommands(int startIndex)
public java.util.List getCommands(int startIndex, int endIndex)
public void addCommand(PDFCmd cmd)
public void addCommands(PDFPage page)
public void addCommands(PDFPage page, java.awt.geom.AffineTransform extra)
page
- the source of other commands. It MUST be finished.extra
- a transform to perform before adding the commands.
If null, no extra transform will be added.public void clearCommands()
public boolean isFinished()
public void waitForFinish() throws java.lang.InterruptedException
java.lang.InterruptedException
public void stop(int width, int height, java.awt.geom.Rectangle2D clip)
public void finish()
public void addPush()
public void addPop()
public void addXform(java.awt.geom.AffineTransform at)
public void addStrokeWidth(float w)
w
- the width of the strokepublic void addEndCap(int capstyle)
capstyle
- the cap style: 0 = BUTT, 1 = ROUND, 2 = SQUAREpublic void addLineJoin(int joinstyle)
joinstyle
- the join style: 0 = MITER, 1 = ROUND, 2 = BEVELpublic void addMiterLimit(float limit)
public void addDash(float[] dashary, float phase)
dashary
- the array of on-off lengthsphase
- offset of the array at the start of the line drawingpublic void addPath(java.awt.geom.GeneralPath path, int style)
path
- the pathstyle
- the style: PDFShapeCmd.STROKE, PDFShapeCmd.FILL,
PDFShapeCmd.BOTH, PDFShapeCmd.CLIP, or some combination.public void addFillPaint(PDFPaint p)
public void addStrokePaint(PDFPaint p)
public void addFillAlpha(float a)
public void addStrokeAlpha(float a)
public void addImage(PDFImage image)
image
- the image to drawpublic void updateImages()