Skip to content

Commit 9289afd

Browse files
Fix PDF/A check for annotations
Additional actions (AA key) are forbidden for annotations in all pdf/a versions.
1 parent 0e355c4 commit 9289afd

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

pdfa/src/main/java/com/itextpdf/pdfa/PdfAConformanceException.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class PdfAConformanceException extends PdfException {
1616
public static final String AllColourChannelsInTheJpeg2000DataShallHaveTheSameBitDepth = "all.colour.channels.in.the.jpeg2000.data.shall.have.the.same.bit-depth";
1717
public static final String AllHalftonesShallHaveHalftonetype1Or5 = "all.halftones.shall.have.halftonetype.1.or.5";
1818
public static final String AnAnnotationDictionaryShallContainTheFKey = "an.annotation.dictionary.shall.contain.the.f.key";
19+
public static final String AnAnnotationDictionaryShallNotContainAAKey = "an.annotation.dictionary.shall.not.contain.aa.key";
1920
public static final String AnAnnotationDictionaryShallNotContainTheCaKeyWithAValueOtherThan1 = "an.annotation.dictionary.shall.not.contain.the.ca.key.with.a.value.other.than.1";
2021
public static final String AnExtgstateDictionaryShallNotContainTheHTPKey = "an.extgstate.dictionary.shall.not.contain.the.HTP.key";
2122
public static final String AnExtgstateDictionaryShallNotContainTheTR2KeyWithAValueOtherThanDefault = "an.extgstate.dictionary.shall.not.contain.the.TR2.key.with.a.value.other.than.default";

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA1Checker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,10 @@ protected void checkAnnotation(PdfDictionary annotDic) {
360360
throw new PdfAConformanceException(PdfAConformanceException.WidgetAnnotationDictionaryOrFieldDictionaryShallNotIncludeAOrAAEntry);
361361
}
362362

363+
if (annotDic.containsKey(PdfName.AA)) {
364+
throw new PdfAConformanceException(PdfAConformanceException.AnAnnotationDictionaryShallNotContainAAKey);
365+
}
366+
363367
if (checkStructure(conformanceLevel)) {
364368
if (contentAnnotations.contains(subtype) && !annotDic.containsKey(PdfName.Contents)) {
365369
throw new PdfAConformanceException(PdfAConformanceException.AnnotationOfType1ShouldHaveContentsKey).setMessageParams(subtype);

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfA2Checker.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ protected void checkAnnotation(PdfDictionary annotDic) {
281281
throw new PdfAConformanceException(PdfAConformanceException.WidgetAnnotationDictionaryOrFieldDictionaryShallNotIncludeAOrAAEntry);
282282
}
283283

284+
if (annotDic.containsKey(PdfName.AA)) {
285+
throw new PdfAConformanceException(PdfAConformanceException.AnAnnotationDictionaryShallNotContainAAKey);
286+
}
287+
284288
if (checkStructure(conformanceLevel)) {
285289
if (contentAnnotations.contains(subtype) && !annotDic.containsKey(PdfName.Contents)) {
286290
throw new PdfAConformanceException(PdfAConformanceException.AnnotationOfType1ShouldHaveContentsKey).setMessageParams(subtype);

pdfa/src/main/java/com/itextpdf/pdfa/checker/PdfAChecker.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.itextpdf.kernel.pdf.PdfStream;
1515
import com.itextpdf.kernel.pdf.PdfString;
1616
import com.itextpdf.kernel.pdf.colorspace.PdfColorSpace;
17+
import com.itextpdf.pdfa.PdfAConformanceException;
1718

1819
import java.util.ArrayList;
1920
import java.util.HashMap;
@@ -231,10 +232,6 @@ private void checkAnnotations(PdfDictionary page) {
231232
if (action != null) {
232233
checkAction(action);
233234
}
234-
action = annotDic.getAsDictionary(PdfName.AA);
235-
if (action != null) {
236-
checkAction(action);
237-
}
238235
}
239236
}
240237
}

pdfa/src/test/java/com/itextpdf/pdfa/PdfAFontTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
public class PdfAFontTest {
3131

3232
static final String sourceFolder = "./src/test/resources/com/itextpdf/pdfa/";
33-
static final String outputDir = "./target/test/PdfA2/";
33+
static final String outputDir = "./target/test/PdfAFontTest/";
3434

3535
@BeforeClass
3636
static public void beforeClass() {

0 commit comments

Comments
 (0)