Package org.apache.pdfbox.contentstream
Class PDFGraphicsStreamEngine
- java.lang.Object
-
- org.apache.pdfbox.contentstream.PDFStreamEngine
-
- org.apache.pdfbox.contentstream.PDFGraphicsStreamEngine
-
- Direct Known Subclasses:
ExtractImages.ImageGraphicsEngine,PageDrawer
public abstract class PDFGraphicsStreamEngine extends PDFStreamEngine
PDFStreamEngine subclass for advanced processing of graphics. This class should be subclassed by end users looking to hook into graphics operations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedPDFGraphicsStreamEngine(PDPage page)Constructor.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidappendRectangle(java.awt.geom.Point2D p0, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.Point2D p3)Append a rectangle to the current path.abstract voidclip(int windingRule)Modify the current clipping path by intersecting it with the current path.abstract voidclosePath()Closes the current path.abstract voidcurveTo(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.abstract voiddrawImage(PDImage pdImage)Draw the image.abstract voidendPath()Ends the current path without filling or stroking it.abstract voidfillAndStrokePath(int windingRule)Fills and then strokes the path.abstract voidfillPath(int windingRule)Fill the path.abstract java.awt.geom.Point2DgetCurrentPoint()Returns the current point of the current path.protected PDPagegetPage()Returns the page.abstract voidlineTo(float x, float y)Draws a line from the current point to (x,y).abstract voidmoveTo(float x, float y)Starts a new path at (x,y).abstract voidshadingFill(COSName shadingName)Fill with Shading.abstract voidstrokePath()Stroke the path.-
Methods inherited from class org.apache.pdfbox.contentstream.PDFStreamEngine
addOperator, applyTextAdjustment, beginMarkedContentSequence, beginText, decreaseLevel, endMarkedContentSequence, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, isShouldProcessColorOperators, markedContentPoint, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processPage, processSoftMask, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showGlyph, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
-
-
-
-
Field Detail
-
page
private final PDPage page
-
-
Constructor Detail
-
PDFGraphicsStreamEngine
protected PDFGraphicsStreamEngine(PDPage page)
Constructor.- Parameters:
page- the page the content stream belongs to
-
-
Method Detail
-
getPage
protected final PDPage getPage()
Returns the page.- Returns:
- the current page
-
appendRectangle
public abstract void appendRectangle(java.awt.geom.Point2D p0, java.awt.geom.Point2D p1, java.awt.geom.Point2D p2, java.awt.geom.Point2D p3) throws java.io.IOExceptionAppend a rectangle to the current path.- Parameters:
p0- starting coordinate of the rectanglep1- second coordinate of the rectanglep2- third coordinate of the rectanglep3- last coordinate of the rectangle- Throws:
java.io.IOException- if the rectangle could not be appended
-
drawImage
public abstract void drawImage(PDImage pdImage) throws java.io.IOException
Draw the image.- Parameters:
pdImage- The image to draw.- Throws:
java.io.IOException- if the image could not be drawn
-
clip
public abstract void clip(int windingRule) throws java.io.IOExceptionModify the current clipping path by intersecting it with the current path. The clipping path will not be updated until the succeeding painting operator is called.- Parameters:
windingRule- The winding rule which will be used for clipping.- Throws:
java.io.IOException- if the clipping path could not be modified
-
moveTo
public abstract void moveTo(float x, float y) throws java.io.IOExceptionStarts a new path at (x,y).- Parameters:
x- the x-coordinate to move toy- the y-coordinate to move to- Throws:
java.io.IOException- if the something went wrong when moving to the given coordinate
-
lineTo
public abstract void lineTo(float x, float y) throws java.io.IOExceptionDraws a line from the current point to (x,y).- Parameters:
x- the X-coordinate of the ending-point of the line to be drawny- the Y-coordinate of the ending-point of the line to be drawn- Throws:
java.io.IOException- if the line could not be drawn
-
curveTo
public abstract void curveTo(float x1, float y1, float x2, float y2, float x3, float y3) throws java.io.IOExceptionDraws a curve from the current point to (x3,y3) using (x1,y1) and (x2,y2) as control points.- Parameters:
x1- the X coordinate of the first Bézier control pointy1- the Y coordinate of the first Bézier control pointx2- the X coordinate of the second Bézier control pointy2- the Y coordinate of the second Bézier control pointx3- the X coordinate of the final end pointy3- the Y coordinate of the final end point- Throws:
java.io.IOException- if the curve could not be drawn
-
getCurrentPoint
public abstract java.awt.geom.Point2D getCurrentPoint() throws java.io.IOExceptionReturns the current point of the current path.- Returns:
- the current point or null
- Throws:
java.io.IOException- if the something went wrong when providing the current point
-
closePath
public abstract void closePath() throws java.io.IOExceptionCloses the current path.- Throws:
java.io.IOException- if the current path could not be closed
-
endPath
public abstract void endPath() throws java.io.IOExceptionEnds the current path without filling or stroking it. The clipping path is updated here.- Throws:
java.io.IOException- if the current path could not be ended
-
strokePath
public abstract void strokePath() throws java.io.IOExceptionStroke the path.- Throws:
java.io.IOException- If there is an IO error while stroking the path.
-
fillPath
public abstract void fillPath(int windingRule) throws java.io.IOExceptionFill the path.- Parameters:
windingRule- The winding rule this path will use.- Throws:
java.io.IOException- if the path could not be filled
-
fillAndStrokePath
public abstract void fillAndStrokePath(int windingRule) throws java.io.IOExceptionFills and then strokes the path.- Parameters:
windingRule- The winding rule this path will use.- Throws:
java.io.IOException- if the path could not be filled and stroke
-
shadingFill
public abstract void shadingFill(COSName shadingName) throws java.io.IOException
Fill with Shading.- Parameters:
shadingName- The name of the Shading Dictionary to use for this fill instruction.- Throws:
java.io.IOException- if the path could not be filled using the given shading
-
-