org.pdfbox.pdfviewer

Class PageDrawer


public class PageDrawer
extends PDFStreamEngine

This will paint a page in a PDF document to a graphics context.
Version:
$Revision: 1.19 $
Author:
Ben Litchfield

Constructor Summary

PageDrawer()
Default constructor, loads properties from file.

Method Summary

void
drawPage(Graphics g, PDPage p, Dimension pageDimension)
This will draw the page to the requested context.
double
fixY(double x, double y)
Fix the y coordinate based on page rotation.
Graphics2D
getGraphics()
Get the graphics that we are currently drawing on.
GeneralPath
getLinePath()
Get the current line path to be drawn.
List
getLineSubPaths()
Get the current list of line paths to be drawn.
Color
getNonStrokingColor()
Get the non stroking color.
PDPage
getPage()
Get the page that is currently being drawn.
Dimension
getPageSize()
Get the size of the page that is currently being drawn.
Color
getStrokingColor()
Get the stroking color.
void
setLinePath(GeneralPath newLinePath)
Set the line path to draw.
void
setLineSubPaths(List newLineSubPaths)
Set the list of line paths to draw.
void
setNonStrokingColor(Color newNonStrokingColor)
Set the non stroking color.
void
setStrokingColor(Color newStrokingColor)
Set the stroking color.
protected void
showCharacter(TextPosition text)
You should override this method if you want to perform an action when a string is being shown.

Methods inherited from class org.pdfbox.util.PDFStreamEngine

getColorSpaces, getCurrentPage, getFonts, getGraphicsStack, getGraphicsState, getGraphicsStates, getResources, getTextLineMatrix, getTextMatrix, getXObjects, processOperator, processOperator, processStream, processSubStream, registerOperatorProcessor, resetEngine, setColorSpaces, setFonts, setGraphicsStack, setGraphicsState, setGraphicsStates, setTextLineMatrix, setTextMatrix, showCharacter, showString

Constructor Details

PageDrawer

public PageDrawer()
            throws IOException
Default constructor, loads properties from file.

Method Details

drawPage

public void drawPage(Graphics g,
                     PDPage p,
                     Dimension pageDimension)
            throws 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.

fixY

public double fixY(double x,
                   double y)
Fix the y coordinate based on page rotation.
Parameters:
x - The x coordinate.
y - The y coordinate.
Returns:
The updated y coordinate.

getGraphics

public Graphics2D getGraphics()
Get the graphics that we are currently drawing on.
Returns:
The graphics we are drawing on.

getLinePath

public GeneralPath getLinePath()
Get the current line path to be drawn.
Returns:
The current line path to be drawn.

getLineSubPaths

public List getLineSubPaths()
Get the current list of line paths to be drawn.
Returns:
The current list of line paths to be drawn.

getNonStrokingColor

public Color getNonStrokingColor()
Get the non stroking color.
Returns:
The non stroking color.

getPage

public PDPage getPage()
Get the page that is currently being drawn.
Returns:
The page that is being drawn.

getPageSize

public Dimension getPageSize()
Get the size of the page that is currently being drawn.
Returns:
The size of the page that is being drawn.

getStrokingColor

public Color getStrokingColor()
Get the stroking color.
Returns:
The stroking color.

setLinePath

public void setLinePath(GeneralPath newLinePath)
Set the line path to draw.
Parameters:
newLinePath - Set the line path to draw.

setLineSubPaths

public void setLineSubPaths(List newLineSubPaths)
Set the list of line paths to draw.
Parameters:
newLineSubPaths - Set the list of line paths to draw.

setNonStrokingColor

public void setNonStrokingColor(Color newNonStrokingColor)
Set the non stroking color.
Parameters:
newNonStrokingColor - The non stroking color.

setStrokingColor

public void setStrokingColor(Color newStrokingColor)
Set the stroking color.
Parameters:
newStrokingColor - The stroking color.

showCharacter

protected void showCharacter(TextPosition text)
You should override this method if you want to perform an action when a string is being shown.
Overrides:
showCharacter in interface PDFStreamEngine
Parameters:
text - The string to display.