Package org.apache.pdfbox.pdfviewer
Class PageDrawer
java.lang.Object
org.apache.pdfbox.util.PDFStreamEngine
org.apache.pdfbox.pdfviewer.PageDrawer
This will paint a page in a PDF document to a graphics context.
- Version:
- $Revision: 1.22 $
- Author:
- Ben Litchfield
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
colorChanged
(boolean bStroking) Deprecated.void
dispose()
Remove all cached resources.void
drawImage
(Image awtImage, AffineTransform at) Draw the AWT image.void
This will draw the page to the requested context.void
endPath()
Set the clipping Path.void
fillPath
(int windingRule) Fill the path.double
fixY
(double y) Fix the y coordinate.Get the graphics that we are currently drawing on.Get the current line path to be drawn.getPage()
Get the page that is currently being drawn.Get the size of the page that is currently being drawn.This will return the current stroke.protected void
You should override this method if you want to perform an action when a text is being processed.void
setClippingPath
(int windingRule) Deprecated.void
setClippingWindingRule
(int windingRule) Set the clipping winding rule.void
setLinePath
(GeneralPath newLinePath) Set the line path to draw.void
setStroke
(BasicStroke newStroke) This will set the current stroke.void
Fill with Shading.void
Deprecated.useshFill(COSName)
instead.protected void
SHFill_Axial
(PDShading Shading) Fill with an Axial Shading.protected void
SHFill_CoonsPatch
(PDShading Shading) Fill with a Coons patch mesh If extending the class, override this and its siblings, not the public SHFill method.protected void
SHFill_FreeGourad
(PDShading Shading) Fill with a Free-form Gourad-shaded triangle mesh.protected void
SHFill_Function
(PDShading Shading) Fill with a Function-based gradient / shading.protected void
SHFill_LatticeGourad
(PDShading Shading) Fill with a Lattice-form Gourad-shaded triangle mesh.protected void
SHFill_Radial
(PDShading Shading) Fill with a Radial gradient / shading.protected void
SHFill_TensorPatch
(PDShading Shading) Fill with a Tensor-product patch mesh.void
Stroke the path.transformedPoint
(double x, double y) use the current transformation matrix to transform a single point.Methods inherited from class org.apache.pdfbox.util.PDFStreamEngine
getColorSpaces, getCurrentPage, getFonts, getGraphicsStack, getGraphicsState, getGraphicsStates, getResources, getTextLineMatrix, getTextMatrix, getTotalCharCnt, getValidCharCnt, getXObjects, inspectFontEncoding, isForceParsing, processEncodedText, processOperator, processOperator, processStream, processSubStream, registerOperatorProcessor, resetEngine, setColorSpaces, setFonts, setForceParsing, setGraphicsStack, setGraphicsState, setGraphicsStates, setTextLineMatrix, setTextMatrix
-
Field Details
-
pageSize
Size of the page. -
page
Current page to be rendered.
-
-
Constructor Details
-
PageDrawer
Default constructor, loads properties from file.- Throws:
IOException
- If there is an error loading properties from the file.
-
-
Method Details
-
drawPage
This will draw the page to the requested context.- Parameters:
g
- The graphics context to draw onto.p
- The page to draw.pageDimension
- The size of the page to draw.- Throws:
IOException
- If there is an IO error while drawing the page.
-
dispose
public void dispose()Remove all cached resources. -
processTextPosition
You should override this method if you want to perform an action when a text is being processed.- Overrides:
processTextPosition
in classPDFStreamEngine
- Parameters:
text
- The text to process
-
getGraphics
Get the graphics that we are currently drawing on.- Returns:
- The graphics we are drawing on.
-
getPage
Get the page that is currently being drawn.- Returns:
- The page that is being drawn.
-
getPageSize
Get the size of the page that is currently being drawn.- Returns:
- The size of the page that is being drawn.
-
fixY
public double fixY(double y) Fix the y coordinate.- Parameters:
y
- The y coordinate.- Returns:
- The updated y coordinate.
-
getLinePath
Get the current line path to be drawn.- Returns:
- The current line path to be drawn.
-
setLinePath
Set the line path to draw.- Parameters:
newLinePath
- Set the line path to draw.
-
fillPath
Fill the path.- Parameters:
windingRule
- The winding rule this path will use.- Throws:
IOException
- If there is an IO error while filling the path.
-
setStroke
This will set the current stroke.- Parameters:
newStroke
- The current stroke.
-
getStroke
This will return the current stroke.- Returns:
- The current stroke.
-
strokePath
Stroke the path.- Throws:
IOException
- If there is an IO error while stroking the path.
-
colorChanged
Deprecated.Called when the color changed.- Parameters:
bStroking
- true for the stroking color, false for the non-stroking color- Throws:
IOException
- if an I/O error occurs
-
transformedPoint
use the current transformation matrix to transform a single point.- Parameters:
x
- x-coordinate of the point to be transformy
- y-coordinate of the point to be transform- Returns:
- the transformed coordinates as Point2D.Double
-
setClippingPath
public void setClippingPath(int windingRule) Deprecated.usesetClippingWindingRule(int)
insteadSet the clipping Path.- Parameters:
windingRule
- The winding rule this path will use.
-
setClippingWindingRule
public void setClippingWindingRule(int windingRule) Set the clipping winding rule.- Parameters:
windingRule
- The winding rule which will be used for clipping.
-
endPath
public void endPath()Set the clipping Path. -
drawImage
Draw the AWT image. Called by Invoke. Moved into PageDrawer so that Invoke doesn't have to reach in here for Graphics as that breaks extensibility.- Parameters:
awtImage
- The image to draw.at
- The transformation to use when drawing.
-
SHFill
Deprecated.useshFill(COSName)
instead.Fill with Shading. Called by SHFill operator.- Parameters:
ShadingName
- The name of the Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
shFill
Fill with Shading. Called by SHFill operator.- Parameters:
shadingName
- The name of the Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the clipping area.
-
SHFill_Function
Fill with a Function-based gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_Axial
Fill with an Axial Shading. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_Radial
Fill with a Radial gradient / shading. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_FreeGourad
Fill with a Free-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_LatticeGourad
Fill with a Lattice-form Gourad-shaded triangle mesh. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_CoonsPatch
Fill with a Coons patch mesh If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_TensorPatch
Fill with a Tensor-product patch mesh. If extending the class, override this and its siblings, not the public SHFill method.- Parameters:
Shading
- The Shading Dictionary to use for this fill instruction.- Throws:
IOException
- If there is an IO error while shade-filling the path/clipping area.
-
setClippingWindingRule(int)
instead