Skip to content

Commit 685ed69

Browse files
committed
Cover AnnotationDefaultAppearance and PdfAction with documentation
DEVSIX-5332
1 parent 6b4a548 commit 685ed69

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

kernel/src/main/java/com/itextpdf/kernel/pdf/action/PdfAction.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,12 @@ private static void validateRemoteDestination(PdfDestination destination) {
709709
}
710710
}
711711

712+
/**
713+
* Validates not remote destination against the PDF specification and in case of invalidity logs a warning.
714+
* See section 12.3.2.2 of ISO 32000-1.
715+
*
716+
* @param destination the {@link PdfDestination destination} to be validated
717+
*/
712718
public static void validateNotRemoteDestination(PdfDestination destination) {
713719
if (destination instanceof PdfExplicitRemoteGoToDestination) {
714720
LoggerFactory.getLogger(PdfAction.class).warn(LogMessageConstant.INVALID_DESTINATION_TYPE);

kernel/src/main/java/com/itextpdf/kernel/pdf/annot/da/AnnotationDefaultAppearance.java

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ This file is part of the iText (R) project.
5353
import java.util.Map;
5454

5555
/**
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.
5766
*/
5867
public class AnnotationDefaultAppearance {
5968

@@ -92,41 +101,93 @@ public class AnnotationDefaultAppearance {
92101
private String rawFontName = "/Helv";
93102
private float fontSize = 0;
94103

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+
*/
95110
public AnnotationDefaultAppearance() {
96111
setFont(StandardAnnotationFont.Helvetica);
97112
setFontSize(12);
98113
}
99114

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+
*/
100122
public AnnotationDefaultAppearance setFont(StandardAnnotationFont font) {
101123
setRawFontName(stdAnnotFontNames.get(font));
102124
return this;
103125
}
104126

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+
*/
105134
public AnnotationDefaultAppearance setFont(ExtendedAnnotationFont font) {
106135
setRawFontName(extAnnotFontNames.get(font));
107136
return this;
108137
}
109138

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+
*/
110145
public AnnotationDefaultAppearance setFontSize(float fontSize) {
111146
this.fontSize = fontSize;
112147
return this;
113148
}
114149

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+
*/
115157
public AnnotationDefaultAppearance setColor(DeviceRgb rgbColor) {
116158
setColorOperand(rgbColor.getColorValue(), "rg");
117159
return this;
118160
}
119161

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+
*/
120169
public AnnotationDefaultAppearance setColor(DeviceCmyk cmykColor) {
121170
setColorOperand(cmykColor.getColorValue(), "k");
122171
return this;
123172
}
124173

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+
*/
125181
public AnnotationDefaultAppearance setColor(DeviceGray grayColor) {
126182
setColorOperand(grayColor.getColorValue(), "g");
127183
return this;
128184
}
129185

186+
/**
187+
* Gets the {@link AnnotationDefaultAppearance}'s representation as {@link PdfString}.
188+
*
189+
* @return the {@link PdfString} representation of this {@link AnnotationDefaultAppearance}
190+
*/
130191
public PdfString toPdfString() {
131192
return new PdfString(MessageFormatUtil.format("{0} {1} Tf {2}", rawFontName, fontSize, colorOperand));
132193
}

0 commit comments

Comments
 (0)