@@ -49,7 +49,17 @@ source product.
49
49
using iText . Kernel . Pdf ;
50
50
51
51
namespace iText . Kernel . Pdf . Annot . DA {
52
- /// <summary>Helper class for setting</summary>
52
+ /// <summary>Helper class for setting annotation default appearance.</summary>
53
+ /// <remarks>
54
+ /// Helper class for setting annotation default appearance. The class provides setters for
55
+ /// font color, font size and font itself.
56
+ /// <para />
57
+ /// Note that only standard font names that do not require font resources are supported.
58
+ /// <para />
59
+ /// Note that it is possible to create annotation with custom font name in DA, but this require
60
+ /// manual resource modifications (you have to put font in DR of AcroForm and use
61
+ /// its resource name in DA) and only Acrobat supports that workflow.
62
+ /// </remarks>
53
63
public class AnnotationDefaultAppearance {
54
64
private static readonly IDictionary < StandardAnnotationFont , String > stdAnnotFontNames = new Dictionary < StandardAnnotationFont
55
65
, String > ( ) ;
@@ -92,41 +102,162 @@ static AnnotationDefaultAppearance() {
92
102
93
103
private float fontSize = 0 ;
94
104
105
+ /// <summary>
106
+ /// Creates the default instance of
107
+ /// <see cref="AnnotationDefaultAppearance"/>.
108
+ /// </summary>
109
+ /// <remarks>
110
+ /// Creates the default instance of
111
+ /// <see cref="AnnotationDefaultAppearance"/>.
112
+ /// <para />
113
+ /// The default font is
114
+ /// <see cref="StandardAnnotationFont.Helvetica"/>
115
+ /// . The default font size is 12.
116
+ /// </remarks>
95
117
public AnnotationDefaultAppearance ( ) {
96
118
SetFont ( StandardAnnotationFont . Helvetica ) ;
97
119
SetFontSize ( 12 ) ;
98
120
}
99
121
122
+ /// <summary>
123
+ /// Sets the
124
+ /// <see cref="AnnotationDefaultAppearance"/>
125
+ /// 's default font.
126
+ /// </summary>
127
+ /// <param name="font">
128
+ /// one of
129
+ /// <see cref="StandardAnnotationFont">standard annotation fonts</see>
130
+ /// to be set as
131
+ /// the default one for this
132
+ /// <see cref="AnnotationDefaultAppearance"/>
133
+ /// </param>
134
+ /// <returns>
135
+ /// this
136
+ /// <see cref="AnnotationDefaultAppearance"/>
137
+ /// </returns>
100
138
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetFont ( StandardAnnotationFont font ) {
101
139
SetRawFontName ( stdAnnotFontNames . Get ( font ) ) ;
102
140
return this ;
103
141
}
104
142
143
+ /// <summary>
144
+ /// Sets the
145
+ /// <see cref="AnnotationDefaultAppearance"/>
146
+ /// 's default font.
147
+ /// </summary>
148
+ /// <param name="font">
149
+ /// one of
150
+ /// <see cref="ExtendedAnnotationFont">extended annotation fonts</see>
151
+ /// to be set as
152
+ /// the default one for this
153
+ /// <see cref="AnnotationDefaultAppearance"/>
154
+ /// </param>
155
+ /// <returns>
156
+ /// this
157
+ /// <see cref="AnnotationDefaultAppearance"/>
158
+ /// </returns>
105
159
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetFont ( ExtendedAnnotationFont font ) {
106
160
SetRawFontName ( extAnnotFontNames . Get ( font ) ) ;
107
161
return this ;
108
162
}
109
163
164
+ /// <summary>
165
+ /// Sets the
166
+ /// <see cref="AnnotationDefaultAppearance"/>
167
+ /// 's default font size.
168
+ /// </summary>
169
+ /// <param name="fontSize">
170
+ /// font size to be set as the
171
+ /// <see cref="AnnotationDefaultAppearance"/>
172
+ /// 's default font size
173
+ /// </param>
174
+ /// <returns>
175
+ /// this
176
+ /// <see cref="AnnotationDefaultAppearance"/>
177
+ /// </returns>
110
178
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetFontSize ( float fontSize ) {
111
179
this . fontSize = fontSize ;
112
180
return this ;
113
181
}
114
182
183
+ /// <summary>
184
+ /// Sets the
185
+ /// <see cref="AnnotationDefaultAppearance"/>
186
+ /// 's default font color.
187
+ /// </summary>
188
+ /// <param name="rgbColor">
189
+ ///
190
+ /// <see cref="iText.Kernel.Colors.DeviceRgb"/>
191
+ /// to be set as the
192
+ /// <see cref="AnnotationDefaultAppearance"/>
193
+ /// 's
194
+ /// default font color
195
+ /// </param>
196
+ /// <returns>
197
+ /// this
198
+ /// <see cref="AnnotationDefaultAppearance"/>
199
+ /// </returns>
115
200
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetColor ( DeviceRgb rgbColor ) {
116
201
SetColorOperand ( rgbColor . GetColorValue ( ) , "rg" ) ;
117
202
return this ;
118
203
}
119
204
205
+ /// <summary>
206
+ /// Sets the
207
+ /// <see cref="AnnotationDefaultAppearance"/>
208
+ /// 's default font color.
209
+ /// </summary>
210
+ /// <param name="cmykColor">
211
+ ///
212
+ /// <see cref="iText.Kernel.Colors.DeviceCmyk"/>
213
+ /// to be set as the
214
+ /// <see cref="AnnotationDefaultAppearance"/>
215
+ /// 's
216
+ /// default font color
217
+ /// </param>
218
+ /// <returns>
219
+ /// this
220
+ /// <see cref="AnnotationDefaultAppearance"/>
221
+ /// </returns>
120
222
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetColor ( DeviceCmyk cmykColor ) {
121
223
SetColorOperand ( cmykColor . GetColorValue ( ) , "k" ) ;
122
224
return this ;
123
225
}
124
226
227
+ /// <summary>
228
+ /// Sets the
229
+ /// <see cref="AnnotationDefaultAppearance"/>
230
+ /// 's default font color.
231
+ /// </summary>
232
+ /// <param name="grayColor">
233
+ ///
234
+ /// <see cref="iText.Kernel.Colors.DeviceGray"/>
235
+ /// to be set as the
236
+ /// <see cref="AnnotationDefaultAppearance"/>
237
+ /// 's
238
+ /// default font color
239
+ /// </param>
240
+ /// <returns>
241
+ /// this
242
+ /// <see cref="AnnotationDefaultAppearance"/>
243
+ /// </returns>
125
244
public virtual iText . Kernel . Pdf . Annot . DA . AnnotationDefaultAppearance SetColor ( DeviceGray grayColor ) {
126
245
SetColorOperand ( grayColor . GetColorValue ( ) , "g" ) ;
127
246
return this ;
128
247
}
129
248
249
+ /// <summary>
250
+ /// Gets the
251
+ /// <see cref="AnnotationDefaultAppearance"/>
252
+ /// 's representation as
253
+ /// <see cref="iText.Kernel.Pdf.PdfString"/>.
254
+ /// </summary>
255
+ /// <returns>
256
+ /// the
257
+ /// <see cref="iText.Kernel.Pdf.PdfString"/>
258
+ /// representation of this
259
+ /// <see cref="AnnotationDefaultAppearance"/>
260
+ /// </returns>
130
261
public virtual PdfString ToPdfString ( ) {
131
262
return new PdfString ( MessageFormatUtil . Format ( "{0} {1} Tf {2}" , rawFontName , fontSize , colorOperand ) ) ;
132
263
}
0 commit comments