class AppearanceGeneratorHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static Operator |
BMC |
private static float |
DEFAULT_FONT_SIZE
The default font size used for multiline text
|
private static float |
DEFAULT_PADDING
The default padding applied by Acrobat to the fields bbox.
|
private PDDefaultAppearanceString |
defaultAppearance |
private static Operator |
EMC |
private PDVariableText |
field |
private static int |
FONTSCALE
The scaling factor for font units to PDF units
|
private static float[] |
HIGHLIGHT_COLOR
The highlight color
The color setting is used by Adobe to display the highlight box for selected entries in a list box.
|
private static org.apache.commons.logging.Log |
LOG |
private java.lang.String |
value |
Constructor and Description |
---|
AppearanceGeneratorHelper(PDVariableText field)
Constructs a COSAppearance from the given field.
|
Modifier and Type | Method and Description |
---|---|
private PDRectangle |
applyPadding(PDRectangle box,
float padding)
Apply padding to a box.
|
private float |
calculateFontSize(PDFont font,
PDRectangle contentRect)
My "not so great" method for calculating the fontsize.
|
private java.awt.geom.AffineTransform |
calculateMatrix(PDRectangle bbox,
int rotation) |
private PDDefaultAppearanceString |
getWidgetDefaultAppearanceString(PDAnnotationWidget widget) |
private void |
initializeAppearanceContent(PDAnnotationWidget widget,
PDAppearanceStream appearanceStream)
Initialize the content of the appearance stream.
|
private void |
insertGeneratedAppearance(PDAnnotationWidget widget,
PDAppearanceStream appearanceStream,
java.io.OutputStream output)
Generate and insert text content and clipping around it.
|
private void |
insertGeneratedCombAppearance(PDPageContentStream contents,
PDAppearanceStream appearanceStream,
PDFont font,
float fontSize)
Generate the appearance for comb fields.
|
private void |
insertGeneratedListboxAppearance(PDPageContentStream contents,
PDAppearanceStream appearanceStream,
PDRectangle contentRect,
PDFont font,
float fontSize) |
private void |
insertGeneratedListboxSelectionHighlight(PDPageContentStream contents,
PDAppearanceStream appearanceStream,
PDFont font,
float fontSize) |
private boolean |
isMultiLine() |
private static boolean |
isValidAppearanceStream(PDAppearanceEntry appearance) |
private PDAppearanceStream |
prepareNormalAppearanceStream(PDAnnotationWidget widget) |
private PDRectangle |
resolveBoundingBox(PDAnnotationWidget fieldWidget,
PDAppearanceStream appearanceStream)
Resolve the bounding box.
|
private int |
resolveRotation(PDAnnotationWidget widget) |
private void |
setAppearanceContent(PDAnnotationWidget widget,
PDAppearanceStream appearanceStream)
Constructs and sets new contents for given appearance stream.
|
void |
setAppearanceValue(java.lang.String apValue)
This is the public method for setting the appearance stream.
|
private boolean |
shallComb()
Determine if the appearance shall provide a comb output.
|
private java.util.List<java.lang.Object> |
tokenize(PDAppearanceStream appearanceStream)
Parses an appearance stream into tokens.
|
private void |
validateAndEnsureAcroFormResources() |
private void |
writeToStream(byte[] data,
PDAppearanceStream appearanceStream)
Writes the stream to the actual stream in the COSStream.
|
private static final org.apache.commons.logging.Log LOG
private static final Operator BMC
private static final Operator EMC
private final PDVariableText field
private PDDefaultAppearanceString defaultAppearance
private java.lang.String value
private static final float[] HIGHLIGHT_COLOR
private static final int FONTSCALE
private static final float DEFAULT_FONT_SIZE
private static final float DEFAULT_PADDING
AppearanceGeneratorHelper(PDVariableText field) throws java.io.IOException
field
- the field which you wish to control the appearance ofjava.io.IOException
private void validateAndEnsureAcroFormResources()
public void setAppearanceValue(java.lang.String apValue) throws java.io.IOException
apValue
- the String value which the appearance should representjava.io.IOException
- If there is an error creating the stream.private static boolean isValidAppearanceStream(PDAppearanceEntry appearance)
private PDAppearanceStream prepareNormalAppearanceStream(PDAnnotationWidget widget)
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws java.io.IOException
java.io.IOException
private int resolveRotation(PDAnnotationWidget widget)
private void initializeAppearanceContent(PDAnnotationWidget widget, PDAppearanceStream appearanceStream) throws java.io.IOException
widget
- the field widgetappearanceStream
- the appearance stream to be usedjava.io.IOException
- in case we can't write to the appearance streamprivate java.util.List<java.lang.Object> tokenize(PDAppearanceStream appearanceStream) throws java.io.IOException
java.io.IOException
private void setAppearanceContent(PDAnnotationWidget widget, PDAppearanceStream appearanceStream) throws java.io.IOException
java.io.IOException
private void insertGeneratedAppearance(PDAnnotationWidget widget, PDAppearanceStream appearanceStream, java.io.OutputStream output) throws java.io.IOException
java.io.IOException
private java.awt.geom.AffineTransform calculateMatrix(PDRectangle bbox, int rotation)
private boolean isMultiLine()
private boolean shallComb()
May be set only if the MaxLen entry is present in the text field dictionary and if the Multiline, Password, and FileSelect flags are clear. If set, the field shall be automatically divided into as many equally spaced positions, or combs, as the value of MaxLen, and the text is laid out into those combs.
private void insertGeneratedCombAppearance(PDPageContentStream contents, PDAppearanceStream appearanceStream, PDFont font, float fontSize) throws java.io.IOException
contents
- the content stream to write toappearanceStream
- the appearance stream usedfont
- the font to be usedfontSize
- the font size to be usedjava.io.IOException
private void insertGeneratedListboxSelectionHighlight(PDPageContentStream contents, PDAppearanceStream appearanceStream, PDFont font, float fontSize) throws java.io.IOException
java.io.IOException
private void insertGeneratedListboxAppearance(PDPageContentStream contents, PDAppearanceStream appearanceStream, PDRectangle contentRect, PDFont font, float fontSize) throws java.io.IOException
java.io.IOException
private void writeToStream(byte[] data, PDAppearanceStream appearanceStream) throws java.io.IOException
java.io.IOException
- If there is an error writing to the streamprivate float calculateFontSize(PDFont font, PDRectangle contentRect) throws java.io.IOException
java.io.IOException
- If there is an error getting the font information.private PDRectangle resolveBoundingBox(PDAnnotationWidget fieldWidget, PDAppearanceStream appearanceStream)
fieldWidget
- the annotation widget.appearanceStream
- the annotations appearance stream.private PDRectangle applyPadding(PDRectangle box, float padding)
box
- box