Top Fields Constructors Methods
org.apache.pdfbox.preflight.annotation

public abstract Class AnnotationValidator

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.preflight.annotation.FreeTextAnnotationValidator, org.apache.pdfbox.preflight.annotation.InkAnnotationValidator, org.apache.pdfbox.preflight.annotation.LineAnnotationValidator, org.apache.pdfbox.preflight.annotation.LinkAnnotationValidator, org.apache.pdfbox.preflight.annotation.MarkupAnnotationValidator, org.apache.pdfbox.preflight.annotation.PopupAnnotationValidator, org.apache.pdfbox.preflight.annotation.PrintMarkAnnotationValidator, org.apache.pdfbox.preflight.annotation.RubberStampAnnotationValidator, org.apache.pdfbox.preflight.annotation.SquareCircleAnnotationValidator, org.apache.pdfbox.preflight.annotation.TextAnnotationValidator, org.apache.pdfbox.preflight.annotation.TrapNetAnnotationValidator, org.apache.pdfbox.preflight.annotation.WidgetAnnotationValidator
Imports
org.apache.pdfbox.cos.COSBase, .COSDictionary, .COSFloat, .COSName, .COSObject, .COSStream, org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject, org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation, .PDAnnotationPopup, .PDAnnotationWidget, .PDAppearanceDictionary, org.apache.pdfbox.preflight.PreflightContext, .ValidationResult.ValidationError, org.apache.pdfbox.preflight.exception.ValidationException, org.apache.pdfbox.preflight.graphic.ICCProfileWrapper, org.apache.pdfbox.preflight.utils.ContextHelper

Field Summary

Modifier and TypeField and Description
protected COSDictionary
annotDictionary

COSDictionary of the annotation

private AnnotationValidatorFactory
protected PreflightContext
protected PDAnnotation
pdAnnot

Instance of PDAnnotation built using the annotDictionary

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean

Returns:

the validation state of the annotations actions.
checkActions
()

Extract a list of ActionManager from the Annotation dictionary and valid them.

protected boolean

Returns:

the validation state of the AP content.
checkAP
()

This method checks the AP entry of the Annotation Dictionary.

protected boolean

Returns:

true if the CA element is missing or if the value is 1.0.
checkCA
()

Check if the CA value is 1.0.

protected boolean

Returns:

true if the C field is present and the RGB profile is used.
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.

protected boolean

Returns:

false if a flag is invalid, true otherwise.
checkFlags
()

Checks if flags of the annotation are authorized.

protected boolean

Returns:

true if validation succeed, false otherwise.
checkMandatoryFields
()

Checks if all mandatory fields of an annotation are present.

protected boolean

Returns:

true if the popup entry is valid, false if not.
checkPopup
()

This method validates the Popup entry.

protected boolean

Returns:

the presence of specific fields.
checkSpecificMandatoryFields
()

Override this method to check the presence of specific fields

private COSBase
protected boolean

Returns:

true if a rgb profile is found, false otherwise.
searchRGBProfile
()

Search the RGB Profile in OutputIntents dictionaries

public final void
setFactory(AnnotationValidatorFactory fact)

Initialize the annotFact attribute of this object.

public boolean

Returns:

true if validation succeed, false otherwise.
validate
()

Execute validation of the Annotation dictionary.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotDictionaryback to summary
protected COSDictionary annotDictionary

COSDictionary of the annotation

annotFactback to summary
private AnnotationValidatorFactory annotFact
ctxback to summary
protected PreflightContext ctx
pdAnnotback to summary
protected PDAnnotation pdAnnot

Instance of PDAnnotation built using the annotDictionary

Constructor Detail

AnnotationValidatorback to summary
public AnnotationValidator(PreflightContext context, COSDictionary annotDictionary)

Method Detail

checkActionsback to summary
protected boolean checkActions() throws ValidationException

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:boolean

the validation state of the annotations actions.

checkAPback to summary
protected boolean checkAP() throws ValidationException

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:boolean

the validation state of the AP content.

checkCAback to summary
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:boolean

true if the CA element is missing or if the value is 1.0.

checkColorsback to summary
protected boolean checkColors() throws ValidationException

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:boolean

true if the C field is present and the RGB profile is used.

checkFlagsback to summary
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
If one of these flags is invalid, the errors list is updated with the ERROR_ANNOT_FORBIDDEN_FLAG ValidationError code.
Returns:boolean

false if a flag is invalid, true otherwise.

checkMandatoryFieldsback to summary
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:boolean

true if validation succeed, false otherwise.

checkPopupback to summary
protected boolean checkPopup() throws ValidationException

This method validates the Popup entry. This entry shall contain an other Annotation. This annotation is validated with the right AnnotationValidator.

Returns:boolean

true if the popup entry is valid, false if not.

checkSpecificMandatoryFieldsback to summary
protected boolean checkSpecificMandatoryFields()

Override this method to check the presence of specific fields

Returns:boolean

the presence of specific fields.

getFieldTypeback to summary
private COSBase getFieldType()
searchRGBProfileback to summary
protected boolean searchRGBProfile() throws ValidationException

Search the RGB Profile in OutputIntents dictionaries

Returns:boolean

true if a rgb profile is found, false otherwise.

setFactoryback to summary
public final void setFactory(AnnotationValidatorFactory fact)

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.

validateback to summary
public boolean validate() throws ValidationException

Execute validation of the Annotation dictionary.

Returns:boolean

true if validation succeed, false otherwise.