Top Description Inners Methods
de.rototor.pdfbox.graphics2d

public Interface IPdfBoxGraphics2DFontTextDrawer

Known Direct Implementers
de.rototor.pdfbox.graphics2d.PdfBoxGraphics2DFontTextDrawer
Imports
org.apache.pdfbox.pdmodel.PDDocument, .PDPageContentStream, .PDResources, org.apache.pdfbox.pdmodel.common.PDRectangle, java.awt.*, java.awt.font.FontRenderContext, java.awt.geom.AffineTransform, java.io.IOException, java.text.AttributedCharacterIterator

Draw text using Fonts

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv

Enviroment for font based drawing of text

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true when the given text can be fully drawn using fonts. return false to have the text drawn as vector shapes
canDrawText
(AttributedCharacterIterator
Has the text and all its properties
iterator
,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv
Environment
env
)

public void
drawText(AttributedCharacterIterator
The text with all properties
iterator
,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv
Environment
env
)

public FontMetrics

Returns:

the resulting font metrics
getFontMetrics
(Font
the Font
font
,
IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv
the Environment
env
)

Method Detail

canDrawTextback to summary
public boolean canDrawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
Parameters
iterator:AttributedCharacterIterator

Has the text and all its properties

env:IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv

Environment

Returns:boolean

true when the given text can be fully drawn using fonts. return false to have the text drawn as vector shapes

Exceptions
IOException:
when a font can not be loaded or a paint can't be applied.
FontFormatException:
when the font file can not be loaded
drawTextback to summary
public void drawText(AttributedCharacterIterator iterator, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
Parameters
iterator:AttributedCharacterIterator

The text with all properties

env:IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv

Environment

Exceptions
IOException:
when a font can not be loaded or a paint can't be applied.
FontFormatException:
when the font file can not be loaded
getFontMetricsback to summary
public FontMetrics getFontMetrics(Font font, IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv env) throws IOException, FontFormatException
Parameters
font:Font

the Font

env:IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv

the Environment

Returns:FontMetrics

the resulting font metrics

de.rototor.pdfbox.graphics2d back to summary

public Interface IPdfBoxGraphics2DFontTextDrawer.IFontTextDrawerEnv


Enviroment for font based drawing of text

Method Summary

Modifier and TypeMethod and Description
public void
applyPaint(Paint
Paint to apply
paint
,
Shape
the shape to draw of the text, if known. This is needed to calculate correct gradients.
shapeToDraw
)

Apply the given paint on the current content stream

public void
applyStroke(Stroke
the stroke to apply
stroke
)

Apply this stroke on the current content stream

public Graphics2D

Returns:

the default calcuation BufferedImage based graphics.
getCalculationGraphics
()

public PDPageContentStream

Returns:

the content stream
getContentStream
()

public AffineTransform

Returns:

the current transform active to draw on this stream
getCurrentEffectiveTransform
()

public PDDocument

Returns:

the document we are writing to
getDocument
()

public Font

Returns:

the current font set on the graphics. This is the "default" font to use when no other font is set on the AttributedCharacterIterator.
getFont
()

public FontRenderContext
public PDRectangle

Returns:

the bbox of the PdfBoxGraphics2D
getGraphicsBBox
()

public Paint

Returns:

the current paint set on the graphics. This is the "default" paint when no other paint is set on on the AttributedCharacterIterator.
getPaint
()

public PDResources

Returns:

the resource of the content stream
getResources
()

Method Detail

applyPaintback to summary
public void applyPaint(Paint paint, Shape shapeToDraw) throws IOException

Apply the given paint on the current content stream

Parameters
paint:Paint

Paint to apply

shapeToDraw:Shape

the shape to draw of the text, if known. This is needed to calculate correct gradients.

Exceptions
IOException:
if an IO error occurs when writing the paint to the content stream.
applyStrokeback to summary
public void applyStroke(Stroke stroke) throws IOException

Apply this stroke on the current content stream

Parameters
stroke:Stroke

the stroke to apply

getCalculationGraphicsback to summary
public Graphics2D getCalculationGraphics()
Returns:Graphics2D

the default calcuation BufferedImage based graphics.

getContentStreamback to summary
public PDPageContentStream getContentStream()
Returns:PDPageContentStream

the content stream

getCurrentEffectiveTransformback to summary
public AffineTransform getCurrentEffectiveTransform()
Returns:AffineTransform

the current transform active to draw on this stream

getDocumentback to summary
public PDDocument getDocument()
Returns:PDDocument

the document we are writing to

getFontback to summary
public Font getFont()
Returns:Font

the current font set on the graphics. This is the "default" font to use when no other font is set on the AttributedCharacterIterator.

getFontRenderContextback to summary
public FontRenderContext getFontRenderContext()
Returns:FontRenderContext

the Graphics2D FontRenderContext

getGraphicsBBoxback to summary
public PDRectangle getGraphicsBBox()
Returns:PDRectangle

the bbox of the PdfBoxGraphics2D

getPaintback to summary
public Paint getPaint()
Returns:Paint

the current paint set on the graphics. This is the "default" paint when no other paint is set on on the AttributedCharacterIterator.

getResourcesback to summary
public PDResources getResources()
Returns:PDResources

the resource of the content stream