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 |
beginMarkedContentSequence(COSName tag,
COSDictionary properties)
Called when a marked content group begins
|
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 |
endMarkedContentSequence()
Called when a a marked content group ends
|
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 |
getNonStrokingPaint()
Returns the non-stroking AWT Paint.
|
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.
|
protected void |
setClip()
Sets the clipping path using caching for performance.
|
void |
shadingFill(COSName shadingName)
Fill with Shading.
|
void |
showAnnotation(PDAnnotation annotation)
Shows the given annotation.
|
protected void |
showFontGlyph(Matrix textRenderingMatrix,
PDFont font,
int code,
Vector displacement)
Called when a glyph is to be processed.
|
void |
showForm(PDFormXObject form)
Shows a form from the content stream.
|
void |
showTransparencyGroup(PDTransparencyGroup form)
Shows a transparency group from the content stream.
|
protected void |
showType3Glyph(Matrix textRenderingMatrix,
PDType3Font font,
int code,
Vector displacement)
Called when a glyph is to be processed.
|
void |
strokePath()
Stroke the path.
|
protected void |
transferClip(Graphics2D graphics)
Transfer clip to the destination device.
|
getPageaddOperator, applyTextAdjustment, decreaseLevel, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showGlyph, showText, showTextString, showTextStrings, transformedPoint, transformWidth, unsupportedOperatorpublic 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.IOExceptionprotected final void setClip()
Graphics.getClip() returns a new object instead of the same one passed to
setClip(). You may need to call this if you override
showGlyph(). See
PDFBOX-5093 for more.protected void transferClip(Graphics2D graphics)
PDGraphicsState.getCurrentClippingPaths(). See
PDFBOX-5258 for sample code.graphics - graphics devicepublic void beginText()
throws IOException
PDFStreamEnginebeginText in class PDFStreamEngineIOException - if there was an error processing the textpublic void endText()
throws IOException
PDFStreamEngineendText in class PDFStreamEngineIOException - if there was an error processing the textprotected void showFontGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException
PDFStreamEngineshowFontGlyph in class PDFStreamEnginetextRenderingMatrix - the current text rendering matrix, Trmfont - the current fontcode - internal PDF character code for the glyphdisplacement - the displacement (i.e. advance) of the glyph in text spaceIOException - if the glyph cannot be processedprotected void showType3Glyph(Matrix textRenderingMatrix, PDType3Font font, int code, Vector displacement) throws IOException
PDFStreamEngineshowType3Glyph in class PDFStreamEnginetextRenderingMatrix - the current text rendering matrix, Trmfont - the current fontcode - internal PDF character code for the glyphdisplacement - 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)
PDFGraphicsStreamEngineappendRectangle in class PDFGraphicsStreamEngineprotected final Paint getNonStrokingPaint() throws IOException
showGlyph(). See
PDFBOX-5093 for more.IOExceptionpublic void strokePath()
throws IOException
PDFGraphicsStreamEnginestrokePath in class PDFGraphicsStreamEngineIOException - If there is an IO error while stroking the path.public void fillPath(int windingRule)
throws IOException
PDFGraphicsStreamEnginefillPath in class PDFGraphicsStreamEnginewindingRule - The winding rule this path will use.IOExceptionpublic void fillAndStrokePath(int windingRule)
throws IOException
fillAndStrokePath in class PDFGraphicsStreamEnginewindingRule - The winding rule this path will use.IOException - If there is an IO error while filling the path.public void clip(int windingRule)
PDFGraphicsStreamEngineclip in class PDFGraphicsStreamEnginewindingRule - The winding rule which will be used for clipping.public void moveTo(float x,
float y)
PDFGraphicsStreamEnginemoveTo in class PDFGraphicsStreamEnginepublic void lineTo(float x,
float y)
PDFGraphicsStreamEnginelineTo in class PDFGraphicsStreamEnginepublic void curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
PDFGraphicsStreamEnginecurveTo in class PDFGraphicsStreamEnginepublic Point2D getCurrentPoint()
PDFGraphicsStreamEnginegetCurrentPoint in class PDFGraphicsStreamEnginepublic void closePath()
PDFGraphicsStreamEngineclosePath in class PDFGraphicsStreamEnginepublic void endPath()
PDFGraphicsStreamEngineendPath in class PDFGraphicsStreamEnginepublic void drawImage(PDImage pdImage) throws IOException
PDFGraphicsStreamEnginedrawImage in class PDFGraphicsStreamEnginepdImage - The image to draw.IOExceptionpublic void shadingFill(COSName shadingName) throws IOException
PDFGraphicsStreamEngineshadingFill in class PDFGraphicsStreamEngineshadingName - The name of the Shading Dictionary to use for this fill instruction.IOExceptionpublic void showAnnotation(PDAnnotation annotation) throws IOException
PDFStreamEngineshowAnnotation in class PDFStreamEngineannotation - An annotation on the current page.IOException - If an error occurred reading the annotationpublic void showForm(PDFormXObject form) throws IOException
showForm in class PDFStreamEngineform - form XObjectIOException - if the form cannot be processedpublic void showTransparencyGroup(PDTransparencyGroup form) throws IOException
PDFStreamEngineshowTransparencyGroup in class PDFStreamEngineform - transparency group (form) XObjectIOException - if the transparency group cannot be processedpublic void beginMarkedContentSequence(COSName tag, COSDictionary properties)
beginMarkedContentSequence in class PDFStreamEnginetag - indicates the role or significance of the sequenceproperties - optional propertiespublic void endMarkedContentSequence()
endMarkedContentSequence in class PDFStreamEngineCopyright © 2002–2021 The Apache Software Foundation. All rights reserved.