org.apache.pdfbox.preflight

## Class PreflightDocument

- java.lang.Object
- - org.apache.pdfbox.pdmodel.PDDocument
  - - org.apache.pdfbox.preflight.PreflightDocument

All Implemented Interfaces:
  Closeable, AutoCloseable

    public class PreflightDocument
    extends org.apache.pdfbox.pdmodel.PDDocument

### Constructor Summary

Constructors
Constructor and Description
`PreflightDocument(org.apache.pdfbox.cos.COSDocument doc, Format format)` Create a preflight document based on the COSDocument and load the default configuration for the given format.
`PreflightDocument(org.apache.pdfbox.cos.COSDocument doc, Format format, PreflightConfiguration config)` Create a preflight document based on the COSDocument that will use the given configuration bean to process the validation.
`PreflightDocument(Format format)` Create an empty preflight document and load the default configuration for the given format.
`PreflightDocument(Format format, PreflightConfiguration cfg)` Create an empty preflight document that will use the given configuration bean to process the validation.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addValidationError(ValidationResult.ValidationError error)`
`PreflightContext` `getContext()`
`ValidationResult` `getResult()`
`Format` `getSpecification()` Returns the format which is used to validate the pdf document.
`void` `setContext(PreflightContext context)`
`void` `setResult(ValidationResult result)`
`void` `validate()` Check that PDDocument is a valid file according to the format given during the object creation.

### Methods inherited from class org.apache.pdfbox.pdmodel.PDDocument

`addPage, addSignature, addSignature, addSignature, addSignature, addSignatureField, close, getCurrentAccessPermission, getDocument, getDocumentCatalog, getDocumentId, getDocumentInformation, getEncryption, getLastSignatureDictionary, getNumberOfPages, getPage, getPages, getResourceCache, getSignatureDictionaries, getSignatureFields, getVersion, importPage, isAllSecurityToBeRemoved, isEncrypted, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, load, protect, registerTrueTypeFontForClosing, removePage, removePage, save, save, save, saveIncremental, saveIncremental, saveIncrementalForExternalSigning, setAllSecurityToBeRemoved, setDocumentId, setDocumentInformation, setEncryptionDictionary, setResourceCache, setVersion`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### PreflightDocument

    public PreflightDocument(Format format)
                      throws IOException

Create an empty preflight document and load the default configuration for the given format.

Parameters:
  `format` - the format used for validation
Throws:
  `IOException`

#### PreflightDocument

    public PreflightDocument(org.apache.pdfbox.cos.COSDocument doc,
                             Format format)

Create a preflight document based on the COSDocument and load the default configuration for the given format.

Parameters:
  `doc` - the underlying COSDocument
  `format` - the format used for validation

#### PreflightDocument

    public PreflightDocument(Format format,
                             PreflightConfiguration cfg)
                      throws IOException

Create an empty preflight document that will use the given configuration bean to process the validation. If the configuration is null, a default configuration will be loaded using the given format.

Parameters:
  `format` - the format used for validation
  `cfg` - the configuration used for validation
Throws:
  `IOException`

#### PreflightDocument

    public PreflightDocument(org.apache.pdfbox.cos.COSDocument doc,
                             Format format,
                             PreflightConfiguration config)

Create a preflight document based on the COSDocument that will use the given configuration bean to process the validation. If the configuration is null, a default configuration will be loaded using the given format.

Parameters:
  `doc` - the underlying COSDocument
  `format` - the format used for validation
  `config` - the configuration used for validation

### Method Detail

#### getResult

    public ValidationResult getResult()

#### setResult

    public void setResult(ValidationResult result)

#### addValidationError

    public void addValidationError(ValidationResult.ValidationError error)

#### getContext

    public PreflightContext getContext()

#### setContext

    public void setContext(PreflightContext context)

#### validate

    public void validate()
                  throws ValidationException

Check that PDDocument is a valid file according to the format given during the object creation.

Throws:
  `ValidationException`

#### getSpecification

    public Format getSpecification()

Returns the format which is used to validate the pdf document.

Returns:
  the format used for validation