Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.interactive.form

pack-priv Class PDDefaultAppearanceString

extends Object
Class Inheritance
Imports
java.io.IOException, java.util.ArrayList, .Arrays, .List, org.apache.pdfbox.contentstream.operator.Operator, .OperatorName, org.apache.pdfbox.cos.COSArray, .COSBase, .COSName, .COSNumber, .COSString, org.apache.pdfbox.pdfparser.PDFStreamParser, org.apache.pdfbox.pdmodel.PDResources, .PDAppearanceContentStream, org.apache.pdfbox.pdmodel.font.PDFont, org.apache.pdfbox.pdmodel.graphics.color.PDColor, .PDColorSpace, .PDDeviceCMYK, .PDDeviceGray, .PDDeviceRGB, org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream

Represents a default appearance string, as found in the /DA entry of free text annotations.

The default appearance string (DA) contains any graphics state or text state operators needed to establish the graphics state parameters, such as text size and colour, for displaying the field’s variable text. Only operators that are allowed within text objects shall occur in this string.

Note

This class is not yet public, as its API is still unstable.

Field Summary

Modifier and TypeField and Description
private static final float
DEFAULT_FONT_SIZE

The default font size used by Acrobat.

private final PDResources
private PDFont
private PDColor
private COSName
private float

Constructor Summary

AccessConstructor and Description
pack-priv
PDDefaultAppearanceString(COSString
DA entry
defaultAppearance
,
PDResources
DR entry
defaultResources
)

Constructor for reading an existing DA string.

Method Summary

Modifier and TypeMethod and Description
pack-priv void
copyNeededResourcesTo(PDAppearanceStream appearanceStream)

Copies any needed resources from the document’s DR dictionary into the stream’s Resources dictionary.

pack-priv PDFont
getFont()

Returns the font.

pack-priv PDColor
getFontColor()

Returns the font color

pack-priv COSName

Returns:

the font name to use for resource lookup
getFontName
()

Get the font name

public float
getFontSize()

Returns the font size.

private void
processAppearanceStringOperators(byte[]
the content to parse.
content
)

Processes the operators of the given content stream.

private void
processOperator(Operator
The operation to perform.
operator
,
List<COSBase>
The list of arguments.
operands
)

This is used to handle an operation.

private void
processSetFont(List<COSBase>
the font name and size
operands
)

Process the set font and font size operator.

private void
processSetFontColor(List<COSBase>
the color components
operands
)

Process the font color operator.

pack-priv void
setFont(PDFont
the font to use.
font
)

Set the font.

pack-priv void
setFontColor(PDColor
the fontColor to use.
fontColor
)

Set the font color.

pack-priv void
setFontName(COSName
the font name to use for resource lookup
fontName
)

Set the font name.

pack-priv void
setFontSize(float
the font size.
fontSize
)

Set the font size.

pack-priv void
writeTo(PDAppearanceContentStream
The content stream.
contents
,
float
The calculated font size to use if the /DA string has a size 0 (autosize). Otherwise the size from the /DA string is used.
zeroFontSize
)

Write font name, font size and color from the /DA string to the given content stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FONT_SIZEback to summary
private static final float DEFAULT_FONT_SIZE

The default font size used by Acrobat.

defaultResourcesback to summary
private final PDResources defaultResources
fontback to summary
private PDFont font
fontColorback to summary
private PDColor fontColor
fontNameback to summary
private COSName fontName
fontSizeback to summary
private float fontSize

Constructor Detail

PDDefaultAppearanceStringback to summary
pack-priv PDDefaultAppearanceString(COSString defaultAppearance, PDResources defaultResources) throws IOException

Constructor for reading an existing DA string.

Parameters
defaultAppearance:COSString

DA entry

defaultResources:PDResources

DR entry

Exceptions
IOException:
If the DA could not be parsed

Method Detail

copyNeededResourcesToback to summary
pack-priv void copyNeededResourcesTo(PDAppearanceStream appearanceStream) throws IOException

Copies any needed resources from the document’s DR dictionary into the stream’s Resources dictionary. Resources with the same name shall be left intact.

getFontback to summary
pack-priv PDFont getFont()

Returns the font.

getFontColorback to summary
pack-priv PDColor getFontColor()

Returns the font color

getFontNameback to summary
pack-priv COSName getFontName()

Get the font name

Returns:COSName

the font name to use for resource lookup

getFontSizeback to summary
public float getFontSize()

Returns the font size.

processAppearanceStringOperatorsback to summary
private void processAppearanceStringOperators(byte[] content) throws IOException

Processes the operators of the given content stream.

Parameters
content:byte[]

the content to parse.

Exceptions
IOException:
if there is an error reading or parsing the content stream.
processOperatorback to summary
private void processOperator(Operator operator, List<COSBase> operands) throws IOException

This is used to handle an operation.

Parameters
operator:Operator

The operation to perform.

operands:List<COSBase>

The list of arguments.

Exceptions
IOException:
If there is an error processing the operation.
processSetFontback to summary
private void processSetFont(List<COSBase> operands) throws IOException

Process the set font and font size operator.

Parameters
operands:List<COSBase>

the font name and size

Exceptions
IOException:
in case there are missing operators or the font is not within the resources
processSetFontColorback to summary
private void processSetFontColor(List<COSBase> operands) throws IOException

Process the font color operator. This is assumed to be an RGB color.

Parameters
operands:List<COSBase>

the color components

Exceptions
IOException:
in case of the color components not matching
setFontback to summary
pack-priv void setFont(PDFont font)

Set the font.

Parameters
font:PDFont

the font to use.

setFontColorback to summary
pack-priv void setFontColor(PDColor fontColor)

Set the font color.

Parameters
fontColor:PDColor

the fontColor to use.

setFontNameback to summary
pack-priv void setFontName(COSName fontName)

Set the font name.

Parameters
fontName:COSName

the font name to use for resource lookup

setFontSizeback to summary
pack-priv void setFontSize(float fontSize)

Set the font size.

Parameters
fontSize:float

the font size.

writeToback to summary
pack-priv void writeTo(PDAppearanceContentStream contents, float zeroFontSize) throws IOException

Write font name, font size and color from the /DA string to the given content stream.

Parameters
contents:PDAppearanceContentStream

The content stream.

zeroFontSize:float

The calculated font size to use if the /DA string has a size 0 (autosize). Otherwise the size from the /DA string is used.