@@ -53,7 +53,16 @@ This file is part of the iText (R) project.
53
53
import java .util .Map ;
54
54
55
55
/**
56
- * Helper class for setting
56
+ * Helper class for setting annotation default appearance. The class provides setters for
57
+ * font color, font size and font itself.
58
+ *
59
+ * <p>
60
+ * Note that only standard font names that do not require font resources are supported.
61
+ *
62
+ * <p>
63
+ * Note that it is possible to create annotation with custom font name in DA, but this require
64
+ * manual resource modifications (you have to put font in DR of AcroForm and use
65
+ * its resource name in DA) and only Acrobat supports that workflow.
57
66
*/
58
67
public class AnnotationDefaultAppearance {
59
68
@@ -92,41 +101,93 @@ public class AnnotationDefaultAppearance {
92
101
private String rawFontName = "/Helv" ;
93
102
private float fontSize = 0 ;
94
103
104
+ /**
105
+ * Creates the default instance of {@link AnnotationDefaultAppearance}.
106
+ *
107
+ * <p>
108
+ * The default font is {@link StandardAnnotationFont#Helvetica}. The default font size is 12.
109
+ */
95
110
public AnnotationDefaultAppearance () {
96
111
setFont (StandardAnnotationFont .Helvetica );
97
112
setFontSize (12 );
98
113
}
99
114
115
+ /**
116
+ * Sets the {@link AnnotationDefaultAppearance}'s default font.
117
+ *
118
+ * @param font one of {@link StandardAnnotationFont standard annotation fonts} to be set as
119
+ * the default one for this {@link AnnotationDefaultAppearance}
120
+ * @return this {@link AnnotationDefaultAppearance}
121
+ */
100
122
public AnnotationDefaultAppearance setFont (StandardAnnotationFont font ) {
101
123
setRawFontName (stdAnnotFontNames .get (font ));
102
124
return this ;
103
125
}
104
126
127
+ /**
128
+ * Sets the {@link AnnotationDefaultAppearance}'s default font.
129
+ *
130
+ * @param font one of {@link ExtendedAnnotationFont extended annotation fonts} to be set as
131
+ * the default one for this {@link AnnotationDefaultAppearance}
132
+ * @return this {@link AnnotationDefaultAppearance}
133
+ */
105
134
public AnnotationDefaultAppearance setFont (ExtendedAnnotationFont font ) {
106
135
setRawFontName (extAnnotFontNames .get (font ));
107
136
return this ;
108
137
}
109
138
139
+ /**
140
+ * Sets the {@link AnnotationDefaultAppearance}'s default font size.
141
+ *
142
+ * @param fontSize font size to be set as the {@link AnnotationDefaultAppearance}'s default font size
143
+ * @return this {@link AnnotationDefaultAppearance}
144
+ */
110
145
public AnnotationDefaultAppearance setFontSize (float fontSize ) {
111
146
this .fontSize = fontSize ;
112
147
return this ;
113
148
}
114
149
150
+ /**
151
+ * Sets the {@link AnnotationDefaultAppearance}'s default font color.
152
+ *
153
+ * @param rgbColor {@link DeviceRgb} to be set as the {@link AnnotationDefaultAppearance}'s
154
+ * default font color
155
+ * @return this {@link AnnotationDefaultAppearance}
156
+ */
115
157
public AnnotationDefaultAppearance setColor (DeviceRgb rgbColor ) {
116
158
setColorOperand (rgbColor .getColorValue (), "rg" );
117
159
return this ;
118
160
}
119
161
162
+ /**
163
+ * Sets the {@link AnnotationDefaultAppearance}'s default font color.
164
+ *
165
+ * @param cmykColor {@link DeviceCmyk} to be set as the {@link AnnotationDefaultAppearance}'s
166
+ * default font color
167
+ * @return this {@link AnnotationDefaultAppearance}
168
+ */
120
169
public AnnotationDefaultAppearance setColor (DeviceCmyk cmykColor ) {
121
170
setColorOperand (cmykColor .getColorValue (), "k" );
122
171
return this ;
123
172
}
124
173
174
+ /**
175
+ * Sets the {@link AnnotationDefaultAppearance}'s default font color.
176
+ *
177
+ * @param grayColor {@link DeviceGray} to be set as the {@link AnnotationDefaultAppearance}'s
178
+ * default font color
179
+ * @return this {@link AnnotationDefaultAppearance}
180
+ */
125
181
public AnnotationDefaultAppearance setColor (DeviceGray grayColor ) {
126
182
setColorOperand (grayColor .getColorValue (), "g" );
127
183
return this ;
128
184
}
129
185
186
+ /**
187
+ * Gets the {@link AnnotationDefaultAppearance}'s representation as {@link PdfString}.
188
+ *
189
+ * @return the {@link PdfString} representation of this {@link AnnotationDefaultAppearance}
190
+ */
130
191
public PdfString toPdfString () {
131
192
return new PdfString (MessageFormatUtil .format ("{0} {1} Tf {2}" , rawFontName , fontSize , colorOperand ));
132
193
}
0 commit comments