Package org.apache.pdfbox.pdfviewer
Class PageDrawer
- java.lang.Object
-
- org.apache.pdfbox.util.PDFStreamEngine
-
- org.apache.pdfbox.pdfviewer.PageDrawer
-
public class PageDrawer extends PDFStreamEngine
This will paint a page in a PDF document to a graphics context.- Version:
- $Revision: 1.22 $
- Author:
- Ben Litchfield
-
-
Constructor Summary
Constructors Constructor Description PageDrawer()
Default constructor, loads properties from file.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
colorChanged(boolean bStroking)
Deprecated.void
dispose()
Remove all cached resources.void
drawImage(java.awt.Image awtImage, java.awt.geom.AffineTransform at)
Draw the AWT image.void
drawPage(java.awt.Graphics g, PDPage p, java.awt.Dimension pageDimension)
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.java.awt.Graphics2D
getGraphics()
Get the graphics that we are currently drawing on.java.awt.geom.GeneralPath
getLinePath()
Get the current line path to be drawn.PDPage
getPage()
Get the page that is currently being drawn.java.awt.Dimension
getPageSize()
Get the size of the page that is currently being drawn.java.awt.BasicStroke
getStroke()
This will return the current stroke.protected void
processTextPosition(TextPosition text)
You should override this method if you want to perform an action when a text is being processed.void
setClippingPath(int windingRule)
Deprecated.usesetClippingWindingRule(int)
insteadvoid
setClippingWindingRule(int windingRule)
Set the clipping winding rule.void
setLinePath(java.awt.geom.GeneralPath newLinePath)
Set the line path to draw.void
setStroke(java.awt.BasicStroke newStroke)
This will set the current stroke.void
shFill(COSName shadingName)
Fill with Shading.void
SHFill(COSName ShadingName)
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
strokePath()
Stroke the path.java.awt.geom.Point2D.Double
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 Detail
-
pageSize
protected java.awt.Dimension pageSize
Size of the page.
-
page
protected PDPage page
Current page to be rendered.
-
-
Method Detail
-
drawPage
public void drawPage(java.awt.Graphics g, PDPage p, java.awt.Dimension pageDimension) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while drawing the page.
-
dispose
public void dispose()
Remove all cached resources.
-
processTextPosition
protected void processTextPosition(TextPosition text)
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
public java.awt.Graphics2D getGraphics()
Get the graphics that we are currently drawing on.- Returns:
- The graphics we are drawing on.
-
getPage
public PDPage getPage()
Get the page that is currently being drawn.- Returns:
- The page that is being drawn.
-
getPageSize
public java.awt.Dimension 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
public java.awt.geom.GeneralPath getLinePath()
Get the current line path to be drawn.- Returns:
- The current line path to be drawn.
-
setLinePath
public void setLinePath(java.awt.geom.GeneralPath newLinePath)
Set the line path to draw.- Parameters:
newLinePath
- Set the line path to draw.
-
fillPath
public void fillPath(int windingRule) throws java.io.IOException
Fill the path.- Parameters:
windingRule
- The winding rule this path will use.- Throws:
java.io.IOException
- If there is an IO error while filling the path.
-
setStroke
public void setStroke(java.awt.BasicStroke newStroke)
This will set the current stroke.- Parameters:
newStroke
- The current stroke.
-
getStroke
public java.awt.BasicStroke getStroke()
This will return the current stroke.- Returns:
- The current stroke.
-
strokePath
public void strokePath() throws java.io.IOException
Stroke the path.- Throws:
java.io.IOException
- If there is an IO error while stroking the path.
-
colorChanged
@Deprecated public void colorChanged(boolean bStroking) throws java.io.IOException
Deprecated.Called when the color changed.- Parameters:
bStroking
- true for the stroking color, false for the non-stroking color- Throws:
java.io.IOException
- if an I/O error occurs
-
transformedPoint
public java.awt.geom.Point2D.Double transformedPoint(double x, double y)
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
public void drawImage(java.awt.Image awtImage, java.awt.geom.AffineTransform at)
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
public void SHFill(COSName ShadingName) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
shFill
public void shFill(COSName shadingName) throws java.io.IOException
Fill with Shading. Called by SHFill operator.- Parameters:
shadingName
- The name of the Shading Dictionary to use for this fill instruction.- Throws:
java.io.IOException
- If there is an IO error while shade-filling the clipping area.
-
SHFill_Function
protected void SHFill_Function(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_Axial
protected void SHFill_Axial(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_Radial
protected void SHFill_Radial(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_FreeGourad
protected void SHFill_FreeGourad(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_LatticeGourad
protected void SHFill_LatticeGourad(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_CoonsPatch
protected void SHFill_CoonsPatch(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
SHFill_TensorPatch
protected void SHFill_TensorPatch(PDShading Shading) throws java.io.IOException
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:
java.io.IOException
- If there is an IO error while shade-filling the path/clipping area.
-
-