Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.interactive.annotation.handlers

public abstract Class PDAbstractAppearanceHandler

extends Object
implements PDAppearanceHandler
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDAppearanceHandler
Known Direct Subclasses
org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDCaretAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDCircleAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDFileAttachmentAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDFreeTextAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDHighlightAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDInkAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDLineAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDLinkAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDPolygonAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDPolylineAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDSoundAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDSquareAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDSquigglyAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDStrikeoutAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDTextAppearanceHandler, org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDUnderlineAppearanceHandler
Imports
java.awt.geom.AffineTransform, java.io.IOException, java.util.Collections, .HashSet, .Set, org.apache.pdfbox.cos.COSStream, org.apache.pdfbox.pdmodel.PDResources, .PDAppearanceContentStream, .PDDocument, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.pdmodel.font.PDFont, .PDType1Font, .Standard14Fonts.FontName, org.apache.pdfbox.pdmodel.graphics.color.PDColor, org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState, org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation, .PDAnnotationLine, .PDAnnotationSquareCircle, .PDAppearanceDictionary, .PDAppearanceEntry, .PDAppearanceStream

Generic handler to generate the fields appearance. Individual handler will provide specific implementations for different field types.

Field Summary

Modifier and TypeField and Description
protected static final Set<String>
ANGLED_STYLES

Line ending styles where the shape changes its angle, e.g. arrows.

private final PDAnnotation
pack-priv static final double
private PDFont
protected final PDDocument
protected static final Set<String>
INTERIOR_COLOR_STYLES

Line ending styles where there is an interior color.

protected static final Set<String>
SHORT_STYLES

Line ending styles where the line has to be drawn shorter (minus line width).

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
pack-priv PDRectangle

Returns:

the padded rectangle.
addRectDifferences
(PDRectangle
the rectangle.
rectangle
,
float[]
the differences to apply.
differences
)

Get a rectangle enlarged by the differences.

pack-priv PDRectangle

Returns:

the padded rectangle.
applyRectDifferences
(PDRectangle
the rectangle.
rectangle
,
float[]
the differences to apply.
differences
)

Get a rectangle with the differences applied to each side.

private static Set<String>
protected COSStream
private static Set<String>
private static Set<String>
pack-priv void
drawArrow(PDAppearanceContentStream
Content stream
cs
,
float x, float y, float
The arm length. Positive goes to the right, negative goes to the left.
len
)

Add the two arms of a horizontal arrow.

pack-priv void
drawCircle(PDAppearanceContentStream
Content stream
cs
,
float x, float y, float
Radius
r
)

Add a circle shape to the path in clockwise direction.

pack-priv void
drawCircle2(PDAppearanceContentStream
Content stream
cs
,
float x, float y, float
Radius
r
)

Add a circle shape to the path in counterclockwise direction.

pack-priv void
drawDiamond(PDAppearanceContentStream
Content stream
cs
,
float x, float y, float
Radius (to a corner)
r
)

Add a square diamond shape (corner on top) to the path.

pack-priv void
drawStyle(String style, final PDAppearanceContentStream cs, float x, float y, float width, boolean hasStroke, boolean hasBackground, boolean
false if left, true if right of an imagined horizontal line (important for arrows).
ending
)

Draw a line ending style.

pack-priv PDAnnotation
pack-priv PDAppearanceDictionary

Returns:

the annotations appearance dictionary
getAppearance
()

Get the annotations appearance dictionary.

private PDAppearanceContentStream
getAppearanceEntryAsContentStream(PDAppearanceEntry appearanceEntry, boolean compress)

pack-priv PDColor
protected PDFont
pack-priv PDAppearanceEntry

Returns:

the appearance entry representing the down appearance.
getDownAppearance
()

Get the annotations down appearance.

private PDAppearanceEntry

Returns:

the appearance entry representing the normal appearance.
getNormalAppearance
()

Get the annotations normal appearance.

pack-priv PDAppearanceContentStream

Returns:

the appearance entry representing the normal appearance.
getNormalAppearanceAsContentStream
()

Get the annotations normal appearance content stream.

pack-priv PDAppearanceContentStream

Returns:

the appearance entry representing the normal appearance.
getNormalAppearanceAsContentStream
(boolean
whether the content stream is to be compressed. Set this to true when creating long content streams.
compress
)

Get the annotations normal appearance content stream.

pack-priv PDRectangle

Returns:

the padded rectangle.
getPaddedRectangle
(PDRectangle
the rectangle.
rectangle
,
float
the padding to apply.
padding
)

Get a padded rectangle.

pack-priv PDRectangle
pack-priv PDAppearanceEntry

Returns:

the appearance entry representing the rollover appearance.
getRolloverAppearance
()

Get the annotations rollover appearance.

pack-priv PDRectangle
handleBorderBox(PDAnnotationSquareCircle annotation, float lineWidth)

pack-priv void
setOpacity(PDAppearanceContentStream contentStream, float opacity)

private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ANGLED_STYLESback to summary
protected static final Set<String> ANGLED_STYLES

Line ending styles where the shape changes its angle, e.g. arrows.

annotationback to summary
private final PDAnnotation annotation
ARROW_ANGLEback to summary
pack-priv static final double ARROW_ANGLE
defaultFontback to summary
private PDFont defaultFont
documentback to summary
protected final PDDocument document
INTERIOR_COLOR_STYLESback to summary
protected static final Set<String> INTERIOR_COLOR_STYLES

Line ending styles where there is an interior color.

SHORT_STYLESback to summary
protected static final Set<String> SHORT_STYLES

Line ending styles where the line has to be drawn shorter (minus line width).

Constructor Detail

PDAbstractAppearanceHandlerback to summary
public PDAbstractAppearanceHandler(PDAnnotation annotation)
PDAbstractAppearanceHandlerback to summary
public PDAbstractAppearanceHandler(PDAnnotation annotation, PDDocument document)

Method Detail

addRectDifferencesback to summary
pack-priv PDRectangle addRectDifferences(PDRectangle rectangle, float[] differences)

Get a rectangle enlarged by the differences.

Creates a new rectangle with differences added to each side. If there are no valid differences, then the original rectangle is returned.

Parameters
rectangle:PDRectangle

the rectangle.

differences:float[]

the differences to apply.

Returns:PDRectangle

the padded rectangle.

applyRectDifferencesback to summary
pack-priv PDRectangle applyRectDifferences(PDRectangle rectangle, float[] differences)

Get a rectangle with the differences applied to each side.

Creates a new rectangle with differences added to each side. If there are no valid differences, then the original rectangle is returned.

Parameters
rectangle:PDRectangle

the rectangle.

differences:float[]

the differences to apply.

Returns:PDRectangle

the padded rectangle.

createAngledStylesback to summary
private static Set<String> createAngledStyles()
createCOSStreamback to summary
protected COSStream createCOSStream()
createInteriorColorStylesback to summary
private static Set<String> createInteriorColorStyles()
createShortStylesback to summary
private static Set<String> createShortStyles()
drawArrowback to summary
pack-priv void drawArrow(PDAppearanceContentStream cs, float x, float y, float len) throws IOException

Add the two arms of a horizontal arrow.

Parameters
cs:PDAppearanceContentStream

Content stream

len:float

The arm length. Positive goes to the right, negative goes to the left.

Exceptions
IOException:
If the content stream could not be written
drawCircleback to summary
pack-priv void drawCircle(PDAppearanceContentStream cs, float x, float y, float r) throws IOException

Add a circle shape to the path in clockwise direction.

Parameters
cs:PDAppearanceContentStream

Content stream

r:float

Radius

Exceptions
IOException:
If the content stream could not be written.
drawCircle2back to summary
pack-priv void drawCircle2(PDAppearanceContentStream cs, float x, float y, float r) throws IOException

Add a circle shape to the path in counterclockwise direction. You'll need this e.g. when drawing a doughnut shape. See "Nonzero Winding Number Rule" for more information.

Parameters
cs:PDAppearanceContentStream

Content stream

r:float

Radius

Exceptions
IOException:
If the content stream could not be written.
drawDiamondback to summary
pack-priv void drawDiamond(PDAppearanceContentStream cs, float x, float y, float r) throws IOException

Add a square diamond shape (corner on top) to the path.

Parameters
cs:PDAppearanceContentStream

Content stream

r:float

Radius (to a corner)

Exceptions
IOException:
If the content stream could not be written
drawStyleback to summary
pack-priv void drawStyle(String style, final PDAppearanceContentStream cs, float x, float y, float width, boolean hasStroke, boolean hasBackground, boolean ending) throws IOException

Draw a line ending style.

Parameters
ending:boolean

false if left, true if right of an imagined horizontal line (important for arrows).

getAnnotationback to summary
pack-priv PDAnnotation getAnnotation()
getAppearanceback to summary
pack-priv PDAppearanceDictionary getAppearance()

Get the annotations appearance dictionary.

This will get the annotations appearance dictionary. If this is not existent an empty appearance dictionary will be created.

Returns:PDAppearanceDictionary

the annotations appearance dictionary

getAppearanceEntryAsContentStreamback to summary
private PDAppearanceContentStream getAppearanceEntryAsContentStream(PDAppearanceEntry appearanceEntry, boolean compress) throws IOException
getColorback to summary
pack-priv PDColor getColor()
getDefaultFontback to summary
protected PDFont getDefaultFont()
getDownAppearanceback to summary
pack-priv PDAppearanceEntry getDownAppearance()

Get the annotations down appearance.

This will get the annotations down appearance. If this is not existent an empty appearance entry will be created.

Returns:PDAppearanceEntry

the appearance entry representing the down appearance.

getNormalAppearanceback to summary
private PDAppearanceEntry getNormalAppearance()

Get the annotations normal appearance.

This will get the annotations normal appearance. If this is not existent an empty appearance entry will be created.

Returns:PDAppearanceEntry

the appearance entry representing the normal appearance.

getNormalAppearanceAsContentStreamback to summary
pack-priv PDAppearanceContentStream getNormalAppearanceAsContentStream() throws IOException

Get the annotations normal appearance content stream.

This will get the annotations normal appearance content stream, to 'draw' to. It will be uncompressed.

Returns:PDAppearanceContentStream

the appearance entry representing the normal appearance.

getNormalAppearanceAsContentStreamback to summary
pack-priv PDAppearanceContentStream getNormalAppearanceAsContentStream(boolean compress) throws IOException

Get the annotations normal appearance content stream.

This will get the annotations normal appearance content stream, to 'draw' to.

Parameters
compress:boolean

whether the content stream is to be compressed. Set this to true when creating long content streams.

Returns:PDAppearanceContentStream

the appearance entry representing the normal appearance.

getPaddedRectangleback to summary
pack-priv PDRectangle getPaddedRectangle(PDRectangle rectangle, float padding)

Get a padded rectangle.

Creates a new rectangle with padding applied to each side. .

Parameters
rectangle:PDRectangle

the rectangle.

padding:float

the padding to apply.

Returns:PDRectangle

the padded rectangle.

getRectangleback to summary
pack-priv PDRectangle getRectangle()
getRolloverAppearanceback to summary
pack-priv PDAppearanceEntry getRolloverAppearance()

Get the annotations rollover appearance.

This will get the annotations rollover appearance. If this is not existent an empty appearance entry will be created.

Returns:PDAppearanceEntry

the appearance entry representing the rollover appearance.

handleBorderBoxback to summary
pack-priv PDRectangle handleBorderBox(PDAnnotationSquareCircle annotation, float lineWidth)
setOpacityback to summary
pack-priv void setOpacity(PDAppearanceContentStream contentStream, float opacity) throws IOException
setTransformationMatrixback to summary
private void setTransformationMatrix(PDAppearanceStream appearanceStream)