Class PDDefaultAppearanceString
java.lang.Object
org.apache.pdfbox.pdmodel.interactive.form.PDDefaultAppearanceString
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
FieldsModifier and TypeFieldDescriptionprivate static final float
The default font size used by Acrobat.private final PDResources
private PDFont
private PDColor
private COSName
private float
-
Constructor Summary
ConstructorsConstructorDescriptionPDDefaultAppearanceString
(COSString defaultAppearance, PDResources defaultResources) Constructor for reading an existing DA string. -
Method Summary
Modifier and TypeMethodDescription(package private) void
copyNeededResourcesTo
(PDAppearanceStream appearanceStream) Copies any needed resources from the document’s DR dictionary into the stream’s Resources dictionary.(package private) PDFont
getFont()
Returns the font.(package private) PDColor
Returns the font color(package private) COSName
Get the font namefloat
Returns the font size.private void
processAppearanceStringOperators
(byte[] content) Processes the operators of the given content stream.private void
processOperator
(Operator operator, List<COSBase> operands) This is used to handle an operation.private void
processSetFont
(List<COSBase> operands) Process the set font and font size operator.private void
processSetFontColor
(List<COSBase> operands) Process the font color operator.(package private) void
Set the font.(package private) void
setFontColor
(PDColor fontColor) Set the font color.(package private) void
setFontName
(COSName fontName) Set the font name.(package private) void
setFontSize
(float fontSize) Set the font size.(package private) void
writeTo
(PDPageContentStream contents, float zeroFontSize) Writes the DA string to the given content stream.
-
Field Details
-
DEFAULT_FONT_SIZE
private static final float DEFAULT_FONT_SIZEThe default font size used by Acrobat.- See Also:
-
defaultResources
-
fontName
-
font
-
fontSize
private float fontSize -
fontColor
-
-
Constructor Details
-
PDDefaultAppearanceString
PDDefaultAppearanceString(COSString defaultAppearance, PDResources defaultResources) throws IOException Constructor for reading an existing DA string.- Parameters:
defaultResources
- DR entrydefaultAppearance
- DA entry- Throws:
IOException
- If the DA could not be parsed
-
-
Method Details
-
processAppearanceStringOperators
Processes the operators of the given content stream.- Parameters:
content
- the content to parse.- Throws:
IOException
- if there is an error reading or parsing the content stream.
-
processOperator
This is used to handle an operation.- Parameters:
operator
- The operation to perform.operands
- The list of arguments.- Throws:
IOException
- If there is an error processing the operation.
-
processSetFont
Process the set font and font size operator.- Parameters:
operands
- the font name and size- Throws:
IOException
- in case there are missing operators or the font is not within the resources
-
processSetFontColor
Process the font color operator. This is assumed to be an RGB color.- Parameters:
operands
- the color components- Throws:
IOException
- in case of the color components not matching
-
getFontName
COSName getFontName()Get the font name- Returns:
- the font name to use for resource lookup
-
setFontName
Set the font name.- Parameters:
fontName
- the font name to use for resource lookup
-
getFont
PDFont getFont()Returns the font. -
setFont
Set the font.- Parameters:
font
- the font to use.
-
getFontSize
public float getFontSize()Returns the font size. -
setFontSize
void setFontSize(float fontSize) Set the font size.- Parameters:
fontSize
- the font size.
-
getFontColor
PDColor getFontColor()Returns the font color -
setFontColor
Set the font color.- Parameters:
fontColor
- the fontColor to use.
-
writeTo
Writes the DA string to the given content stream.- Throws:
IOException
-
copyNeededResourcesTo
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.- Throws:
IOException
-