public class PageDrawer extends PDFGraphicsStreamEngine
If you want to do custom graphics processing rather than Graphics2D rendering, then you should
subclass PDFGraphicsStreamEngine
instead. Subclassing PageDrawer is only suitable for
cases where the goal is to render onto a Graphics2D
surface. In that case you'll also
have to subclass PDFRenderer
and modify
PDFRenderer.createPageDrawer(PageDrawerParameters)
.
Constructor and Description |
---|
PageDrawer(PageDrawerParameters parameters)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
appendRectangle(Point2D p0,
Point2D p1,
Point2D p2,
Point2D p3)
Append a rectangle to the current path.
|
void |
beginText()
Called when the BT operator is encountered.
|
void |
clip(int windingRule)
Modify the current clipping path by intersecting it with the current path.
|
void |
closePath()
Closes the current path.
|
void |
curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Draws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.
|
void |
drawImage(PDImage pdImage)
Draw the image.
|
void |
drawPage(Graphics g,
PDRectangle pageSize)
Draws the page to the requested context.
|
void |
endPath()
Ends the current path without filling or stroking it.
|
void |
endText()
Called when the ET operator is encountered.
|
void |
fillAndStrokePath(int windingRule)
Fills and then strokes the path.
|
void |
fillPath(int windingRule)
Fill the path.
|
AnnotationFilter |
getAnnotationFilter()
Return the AnnotationFilter.
|
Point2D |
getCurrentPoint()
Returns the current point of the current path.
|
protected Graphics2D |
getGraphics()
Returns the underlying Graphics2D.
|
protected GeneralPath |
getLinePath()
Returns the current line path.
|
protected Paint |
getPaint(PDColor color)
Returns an AWT paint for the given PDColor.
|
PDFRenderer |
getRenderer()
Returns the parent renderer.
|
void |
lineTo(float x,
float y)
Draws a line from the current point to (x,y).
|
void |
moveTo(float x,
float y)
Starts a new path at (x,y).
|
void |
setAnnotationFilter(AnnotationFilter annotationFilter)
Set the AnnotationFilter.
|
void |
shadingFill(COSName shadingName)
Fill with Shading.
|
void |
showAnnotation(PDAnnotation annotation)
Shows the given annotation.
|
protected void |
showFontGlyph(Matrix textRenderingMatrix,
PDFont font,
int code,
String unicode,
Vector displacement)
Called when a glyph is to be processed.This method is intended for overriding in subclasses,
the default implementation does nothing.
|
void |
showTransparencyGroup(PDTransparencyGroup form)
Shows a transparency group from the content stream.
|
void |
strokePath()
Stroke the path.
|
getPage
addOperator, applyTextAdjustment, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getResources, getTextLineMatrix, getTextMatrix, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, registerOperatorProcessor, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showForm, showGlyph, showText, showTextString, showTextStrings, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
public PageDrawer(PageDrawerParameters parameters) throws IOException
parameters
- Parameters for page drawing.IOException
- If there is an error loading properties from the file.public AnnotationFilter getAnnotationFilter()
public void setAnnotationFilter(AnnotationFilter annotationFilter)
Allows to only render annotation accepted by the filter.
annotationFilter
- the AnnotationFilterpublic final PDFRenderer getRenderer()
protected final Graphics2D getGraphics()
protected final GeneralPath getLinePath()
public void drawPage(Graphics g, PDRectangle pageSize) throws IOException
g
- The graphics context to draw onto.pageSize
- The size of the page to draw.IOException
- If there is an IO error while drawing the page.protected Paint getPaint(PDColor color) throws IOException
color
- The color to get a paint for. This can be an actual color or a pattern.IOException
public void beginText() throws IOException
PDFStreamEngine
beginText
in class PDFStreamEngine
IOException
- if there was an error processing the textpublic void endText() throws IOException
PDFStreamEngine
endText
in class PDFStreamEngine
IOException
- if there was an error processing the textprotected void showFontGlyph(Matrix textRenderingMatrix, PDFont font, int code, String unicode, Vector displacement) throws IOException
PDFStreamEngine
showFontGlyph
in class PDFStreamEngine
textRenderingMatrix
- the current text rendering matrix, Trmfont
- the current fontcode
- internal PDF character code for the glyphunicode
- the Unicode text for this glyph, or null if the PDF does provide itdisplacement
- the displacement (i.e. advance) of the glyph in text spaceIOException
- if the glyph cannot be processedpublic void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3)
PDFGraphicsStreamEngine
appendRectangle
in class PDFGraphicsStreamEngine
p0
- point P0 of the rectangle.p1
- point P1 of the rectangle.p2
- point P2 of the rectangle.p3
- point P3 of the rectangle.public void strokePath() throws IOException
PDFGraphicsStreamEngine
strokePath
in class PDFGraphicsStreamEngine
IOException
- If there is an IO error while stroking the path.public void fillPath(int windingRule) throws IOException
PDFGraphicsStreamEngine
fillPath
in class PDFGraphicsStreamEngine
windingRule
- The winding rule this path will use.IOException
- if something went wrong.public void fillAndStrokePath(int windingRule) throws IOException
fillAndStrokePath
in class PDFGraphicsStreamEngine
windingRule
- The winding rule this path will use.IOException
- If there is an IO error while filling the path.public void clip(int windingRule)
PDFGraphicsStreamEngine
clip
in class PDFGraphicsStreamEngine
windingRule
- The winding rule which will be used for clipping.public void moveTo(float x, float y)
PDFGraphicsStreamEngine
moveTo
in class PDFGraphicsStreamEngine
x
- x-coordinate of the target point.y
- y-coordinate of the target point.public void lineTo(float x, float y)
PDFGraphicsStreamEngine
lineTo
in class PDFGraphicsStreamEngine
x
- x-coordinate of the end point of the line.y
- y-coordinate of the end point of the line.public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
PDFGraphicsStreamEngine
curveTo
in class PDFGraphicsStreamEngine
x1
- x-coordinate of the first control point.y1
- y-coordinate of the first control point.x2
- x-coordinate of the second control point.y2
- y-coordinate of the second control point.x3
- x-coordinate of the end point of the curve.y3
- y-coordinate of the end point of the curve.public Point2D getCurrentPoint()
PDFGraphicsStreamEngine
getCurrentPoint
in class PDFGraphicsStreamEngine
public void closePath()
PDFGraphicsStreamEngine
closePath
in class PDFGraphicsStreamEngine
public void endPath()
PDFGraphicsStreamEngine
endPath
in class PDFGraphicsStreamEngine
public void drawImage(PDImage pdImage) throws IOException
PDFGraphicsStreamEngine
drawImage
in class PDFGraphicsStreamEngine
pdImage
- The image to draw.IOException
- if something went wrong.public void shadingFill(COSName shadingName) throws IOException
PDFGraphicsStreamEngine
shadingFill
in class PDFGraphicsStreamEngine
shadingName
- The name of the Shading Dictionary to use for this fill instruction.IOException
- if something went wrong.public void showAnnotation(PDAnnotation annotation) throws IOException
PDFStreamEngine
showAnnotation
in class PDFStreamEngine
annotation
- An annotation on the current page.IOException
- If an error occurred reading the annotationpublic void showTransparencyGroup(PDTransparencyGroup form) throws IOException
PDFStreamEngine
showTransparencyGroup
in class PDFStreamEngine
form
- transparency group (form) XObjectIOException
- if the transparency group cannot be processedCopyright © 2002–2018 The Apache Software Foundation. All rights reserved.