Skip to content

Commit e6fb263

Browse files
committed
Fix annotation UA-1 checks
DEVSIX-8679
1 parent cbb82b1 commit e6fb263

File tree

7 files changed

+93
-116
lines changed

7 files changed

+93
-116
lines changed

pdfua/src/main/java/com/itextpdf/pdfua/checkers/utils/AnnotationCheckUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,9 @@ public void processElement(IStructureNode elem) {
126126
throw new PdfUAConformanceException(PdfUAExceptionMessageConstants.ANNOT_TRAP_NET_IS_NOT_PERMITTED);
127127
}
128128

129-
if (!PdfName.Widget.equals(subtype) && !(annotObj.containsKey(PdfName.Contents)
130-
|| annotObj.containsKey(PdfName.Alt))) {
129+
PdfStructElem parent = (PdfStructElem) objRef.getParent();
130+
if (!PdfName.Widget.equals(subtype) &&
131+
!(annotObj.containsKey(PdfName.Contents) || (parent != null && parent.getAlt() != null))) {
131132
throw new PdfUAConformanceException(MessageFormatUtil.format(
132133
PdfUAExceptionMessageConstants.ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY, subtype.getValue()));
133134
}

pdfua/src/main/java/com/itextpdf/pdfua/exceptions/PdfUAExceptionMessageConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ public final class PdfUAExceptionMessageConstants {
101101
"in pdf encryption dictionary.";
102102
public static final String TENTH_BIT_OF_P_VALUE_IN_ENCRYPTION_SHOULD_BE_NON_ZERO = "10th bit of P value of " +
103103
"Encryption dictionary should be 1 if the document is tagged.";
104-
public static final String ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY = "Annotation of type {0} should " +
105-
"have contents or alternate description.";
104+
public static final String ANNOTATION_OF_TYPE_0_SHOULD_HAVE_CONTENTS_OR_ALT_KEY = "Annotation of type {0} shall " +
105+
"have contents or alternate description (in the form of an Alt entry in the enclosing structure element).";
106106
public static final String LINK_ANNOTATION_SHOULD_HAVE_CONTENTS_KEY = "Annotation of type Link " +
107107
"shall contain an alternate description via their Contents key.";
108108
public static final String CT_OR_ALT_ENTRY_IS_MISSING_IN_MEDIA_CLIP = "CT or Alt entry is missing from the media " +

pdfua/src/test/java/com/itextpdf/pdfua/PdfUAAnnotationsTest.java

Lines changed: 88 additions & 112 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)