Skip to content

Commit 4b6a0d0

Browse files
ars18wrwiText-CI
authored andcommitted
Cover AnnotationDefaultAppearance and PdfAction with documentation
DEVSIX-5332 Autoported commit. Original commit hash: [685ed690c]
1 parent 2259822 commit 4b6a0d0

File tree

3 files changed

+144
-2
lines changed

3 files changed

+144
-2
lines changed

itext/itext.kernel/itext/kernel/pdf/action/PdfAction.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,17 @@ private static void ValidateRemoteDestination(PdfDestination destination) {
729729
}
730730
}
731731

732+
/// <summary>Validates not remote destination against the PDF specification and in case of invalidity logs a warning.
733+
/// </summary>
734+
/// <remarks>
735+
/// Validates not remote destination against the PDF specification and in case of invalidity logs a warning.
736+
/// See section 12.3.2.2 of ISO 32000-1.
737+
/// </remarks>
738+
/// <param name="destination">
739+
/// the
740+
/// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination">destination</see>
741+
/// to be validated
742+
/// </param>
732743
public static void ValidateNotRemoteDestination(PdfDestination destination) {
733744
if (destination is PdfExplicitRemoteGoToDestination) {
734745
LogManager.GetLogger(typeof(iText.Kernel.Pdf.Action.PdfAction)).Warn(iText.IO.LogMessageConstant.INVALID_DESTINATION_TYPE

itext/itext.kernel/itext/kernel/pdf/annot/da/AnnotationDefaultAppearance.cs

Lines changed: 132 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,17 @@ source product.
4949
using iText.Kernel.Pdf;
5050

5151
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>
5363
public class AnnotationDefaultAppearance {
5464
private static readonly IDictionary<StandardAnnotationFont, String> stdAnnotFontNames = new Dictionary<StandardAnnotationFont
5565
, String>();
@@ -92,41 +102,162 @@ static AnnotationDefaultAppearance() {
92102

93103
private float fontSize = 0;
94104

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>
95117
public AnnotationDefaultAppearance() {
96118
SetFont(StandardAnnotationFont.Helvetica);
97119
SetFontSize(12);
98120
}
99121

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>
100138
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetFont(StandardAnnotationFont font) {
101139
SetRawFontName(stdAnnotFontNames.Get(font));
102140
return this;
103141
}
104142

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>
105159
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetFont(ExtendedAnnotationFont font) {
106160
SetRawFontName(extAnnotFontNames.Get(font));
107161
return this;
108162
}
109163

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>
110178
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetFontSize(float fontSize) {
111179
this.fontSize = fontSize;
112180
return this;
113181
}
114182

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>
115200
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetColor(DeviceRgb rgbColor) {
116201
SetColorOperand(rgbColor.GetColorValue(), "rg");
117202
return this;
118203
}
119204

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>
120222
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetColor(DeviceCmyk cmykColor) {
121223
SetColorOperand(cmykColor.GetColorValue(), "k");
122224
return this;
123225
}
124226

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>
125244
public virtual iText.Kernel.Pdf.Annot.DA.AnnotationDefaultAppearance SetColor(DeviceGray grayColor) {
126245
SetColorOperand(grayColor.GetColorValue(), "g");
127246
return this;
128247
}
129248

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>
130261
public virtual PdfString ToPdfString() {
131262
return new PdfString(MessageFormatUtil.Format("{0} {1} Tf {2}", rawFontName, fontSize, colorOperand));
132263
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6b4a548067d754ff7b82375a1cc12495a83db152
1+
685ed690cca02736d8eba8043fc6b5ff487475a2

0 commit comments

Comments
 (0)