Author: tilman Date: Mon Jul 4 16:04:21 2016 New Revision: 1751328 URL: http://svn.apache.org/viewvc?rev=1751328&view=rev Log: PDFBOX-3408: Go up the hierarchy to get the type
Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java Modified: pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java?rev=1751328&r1=1751327&r2=1751328&view=diff ============================================================================== --- pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java (original) +++ pdfbox/branches/2.0/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java Mon Jul 4 16:04:21 2016 @@ -190,7 +190,7 @@ public abstract class AnnotationValidato { COSBase apn = apDict.getItem(COSName.N); COSBase subtype = annotDictionary.getItem(COSName.SUBTYPE); - COSBase ft = annotDictionary.getItem(COSName.FT); + COSBase ft = getFieldType(); if (COSName.WIDGET.equals(subtype) && COSName.BTN.equals(ft)) { // TECHNICAL CORRIGENDUM 2 for ISO 19005-1:2005 (PDF/A-1) @@ -339,4 +339,25 @@ public abstract class AnnotationValidato { this.annotFact = fact; } + + private COSBase getFieldType() + { + COSBase ft = annotDictionary.getDictionaryObject(COSName.FT); + COSDictionary parent = annotDictionary; + while (ft == null) + { + // /FT could be in parent, so look upwards + COSBase parentBase = parent.getDictionaryObject(COSName.PARENT); + if (parentBase instanceof COSDictionary) + { + parent = (COSDictionary) parentBase; + ft = parent.getDictionaryObject(COSName.FT); + } + else + { + break; + } + } + return ft; + } }