Class AnnotationValidator
java.lang.Object
org.apache.pdfbox.preflight.annotation.AnnotationValidator
- Direct Known Subclasses:
FreeTextAnnotationValidator
,InkAnnotationValidator
,LineAnnotationValidator
,LinkAnnotationValidator
,MarkupAnnotationValidator
,PopupAnnotationValidator
,PrintMarkAnnotationValidator
,RubberStampAnnotationValidator
,SquareCircleAnnotationValidator
,TextAnnotationValidator
,TrapNetAnnotationValidator
,WidgetAnnotationValidator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected COSDictionary
COSDictionary of the annotationprivate AnnotationValidatorFactory
private COSDocument
protected PreflightContext
protected PDAnnotation
Instance of PDAnnotation built using the annotDictionary -
Constructor Summary
ConstructorsConstructorDescriptionAnnotationValidator
(PreflightContext context, COSDictionary annotDictionary) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Extract a list of ActionManager from the Annotation dictionary and valid them.protected boolean
checkAP()
This method checks the AP entry of the Annotation Dictionary.protected boolean
checkCA()
Check if the CA value is 1.0.protected boolean
Return true if the C field is present in the Annotation dictionary and if the RGB profile is used in the DestOutputProfile of the OutputIntent dictionary.protected boolean
Checks if flags of the annotation are authorized.protected boolean
Checks if all mandatory fields of an annotation are present.protected boolean
This method validates the Popup entry.protected boolean
Override this method to check the presence of specific fieldsprivate COSBase
protected boolean
Search the RGB Profile in OutputIntents dictionariesfinal void
Initialize the annotFact attribute of this object.boolean
validate()
Execute validation of the Annotation dictionary.
-
Field Details
-
annotFact
-
ctx
-
cosDocument
-
annotDictionary
COSDictionary of the annotation -
pdAnnot
Instance of PDAnnotation built using the annotDictionary
-
-
Constructor Details
-
AnnotationValidator
-
-
Method Details
-
checkFlags
protected boolean checkFlags()Checks if flags of the annotation are authorized.- Print flag must be 1
- NoView flag must be 0
- Hidden flag must be 0
- Invisible flag must be 0
- Returns:
- false if a flag is invalid, true otherwise.
-
checkCA
protected boolean checkCA()Check if the CA value is 1.0. Return true if the CA element is missing or if the value is 1.0. Return false otherwise and update the list of errors present in the DocumentHandler.- Returns:
- true if the CA element is missing or if the value is 1.0.
-
checkColors
Return true if the C field is present in the Annotation dictionary and if the RGB profile is used in the DestOutputProfile of the OutputIntent dictionary.- Returns:
- true if the C field is present and the RGB profile is used.
- Throws:
ValidationException
-
searchRGBProfile
Search the RGB Profile in OutputIntents dictionaries- Returns:
- true if a rgb profile is found, false otherwise.
- Throws:
ValidationException
-
checkAP
This method checks the AP entry of the Annotation Dictionary. If the AP key is missing, this method returns true. If the AP key exists, only the N entry is authorized and must be a Stream which define the appearance of the annotation. (Currently, only the type of the N entry is checked because of the Appearance stream is a Form XObject, so it will be checked by the Graphics Helper) If the AP content isn't valid, this method return false and updates the errors list.- Returns:
- the validation state of the AP content.
- Throws:
ValidationException
-
checkActions
Extract a list of ActionManager from the Annotation dictionary and valid them. If an action is invalid, the errors list is updated and the method returns false. Otherwise, the method returns true and the errors list doesn't change.- Returns:
- the validation state of the annotations actions.
- Throws:
ValidationException
-
checkPopup
This method validates the Popup entry. This entry shall contain an other Annotation. This annotation is validated with the right AnnotationValidator.- Returns:
- true if the popup entry is valid, false if not.
- Throws:
ValidationException
-
validate
Execute validation of the Annotation dictionary.- Returns:
- true if validation succeed, false otherwise.
- Throws:
ValidationException
-
checkMandatoryFields
protected boolean checkMandatoryFields()Checks if all mandatory fields of an annotation are present. If some fields are missing, the method returns false and the errors list is updated.- Returns:
- true if validation succeed, false otherwise.
-
checkSpecificMandatoryFields
protected boolean checkSpecificMandatoryFields()Override this method to check the presence of specific fields- Returns:
- the presence of specific fields.
-
setFactory
Initialize the annotFact attribute of this object. This method must be called by the Factory at the creation of this object. Only the Factory should call this method.- Parameters:
fact
-
-
getFieldType
-