Package org.apache.pdfbox.preflight
Class PreflightContext
- java.lang.Object
-
- org.apache.pdfbox.preflight.PreflightContext
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class PreflightContext extends java.lang.Object implements java.io.Closeable
-
-
Field Summary
Fields Modifier and Type Field Description private PreflightConfiguration
config
private java.lang.Integer
currentPageNumber
private javax.activation.DataSource
dataSource
The datasource to load the document from.private PreflightDocument
document
The PDFbox object representation of the PDF source.private long
fileLen
private java.util.Map<COSBase,FontContainer<?>>
fontContainers
Contains the list of font name embedded in the PDF document.private boolean
iccProfileAlreadySearched
private ICCProfileWrapper
iccProfileWrapper
This wrapper contains the ICCProfile used by the PDF file.private XMPMetadata
metadata
MetaData of the current pdf file.private java.util.Set<COSObjectable>
processedSet
private PreflightPath
validationPath
private XrefTrailerResolver
xrefTrailerResolver
Contains all Xref/trailer objects and resolves them into single object using startxref reference.
-
Constructor Summary
Constructors Constructor Description PreflightContext(javax.activation.DataSource dataSource)
Create the DocumentHandler using the DataSource which represent the PDF file to check.PreflightContext(javax.activation.DataSource dataSource, PreflightConfiguration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFontContainer(COSBase cBase, FontContainer<?> fc)
Add a FontContainer to allow TextObject validation.void
addToProcessedSet(COSObjectable cos)
Add the argument to the set of processed elements,void
addValidationError(ValidationResult.ValidationError error)
Add the given error the PreflightDocumentvoid
addValidationErrors(java.util.List<ValidationResult.ValidationError> errors)
Add the given errors the PreflightDocumentvoid
close()
Close all opened resourcesPreflightConfiguration
getConfig()
java.lang.Integer
getCurrentPageNumber()
Returns the current page number or null if none is known.PreflightDocument
getDocument()
long
getFileLen()
FontContainer<?>
getFontContainer(COSBase cBase)
Return the FontContainer identified by the COSBase.ICCProfileWrapper
getIccProfileWrapper()
XMPMetadata
getMetadata()
javax.activation.DataSource
getSource()
PreflightPath
getValidationPath()
XrefTrailerResolver
getXrefTrailerResolver()
boolean
isComplete()
boolean
isIccProfileAlreadySearched()
boolean
isInProcessedSet(COSObjectable cos)
Tell if the argument is in the set of processed elements.void
setConfig(PreflightConfiguration config)
void
setCurrentPageNumber(java.lang.Integer currentPageNumber)
Sets or resets the current page number.void
setDocument(PreflightDocument document)
Initialize the PDFBox object which present the PDF File.void
setFileLen(long fileLen)
void
setIccProfileAlreadySearched(boolean iccProfileAlreadySearched)
void
setIccProfileWrapper(ICCProfileWrapper iccProfileWrapper)
void
setMetadata(XMPMetadata metadata)
void
setValidationPath(PreflightPath validationPath)
void
setXrefTrailerResolver(XrefTrailerResolver xrefTrailerResolver)
-
-
-
Field Detail
-
fontContainers
private final java.util.Map<COSBase,FontContainer<?>> fontContainers
Contains the list of font name embedded in the PDF document.
-
document
private PreflightDocument document
The PDFbox object representation of the PDF source.
-
dataSource
private javax.activation.DataSource dataSource
The datasource to load the document from. Needed by StreamValidationProcess.
-
xrefTrailerResolver
private XrefTrailerResolver xrefTrailerResolver
Contains all Xref/trailer objects and resolves them into single object using startxref reference.
-
iccProfileWrapper
private ICCProfileWrapper iccProfileWrapper
This wrapper contains the ICCProfile used by the PDF file.
-
iccProfileAlreadySearched
private boolean iccProfileAlreadySearched
-
metadata
private XMPMetadata metadata
MetaData of the current pdf file.
-
config
private PreflightConfiguration config
-
validationPath
private PreflightPath validationPath
-
processedSet
private final java.util.Set<COSObjectable> processedSet
-
currentPageNumber
private java.lang.Integer currentPageNumber
-
fileLen
private long fileLen
-
-
Constructor Detail
-
PreflightContext
public PreflightContext(javax.activation.DataSource dataSource)
Create the DocumentHandler using the DataSource which represent the PDF file to check.- Parameters:
dataSource
-
-
PreflightContext
public PreflightContext(javax.activation.DataSource dataSource, PreflightConfiguration configuration)
-
-
Method Detail
-
getMetadata
public XMPMetadata getMetadata()
- Returns:
- the metadata
-
setMetadata
public void setMetadata(XMPMetadata metadata)
- Parameters:
metadata
- the metadata to set
-
getDocument
public PreflightDocument getDocument()
- Returns:
- the PDFBox object representation of the document
-
getXrefTrailerResolver
public XrefTrailerResolver getXrefTrailerResolver()
-
setXrefTrailerResolver
public void setXrefTrailerResolver(XrefTrailerResolver xrefTrailerResolver)
-
setDocument
public void setDocument(PreflightDocument document)
Initialize the PDFBox object which present the PDF File.- Parameters:
document
-
-
getSource
public javax.activation.DataSource getSource()
- Returns:
- The datasource of the pdf document
-
isComplete
public boolean isComplete()
-
addFontContainer
public void addFontContainer(COSBase cBase, FontContainer<?> fc)
Add a FontContainer to allow TextObject validation.- Parameters:
cBase
- the COSBase for the font container.fc
- the font container.
-
getFontContainer
public FontContainer<?> getFontContainer(COSBase cBase)
Return the FontContainer identified by the COSBase. If the given object is missing from thefontContainers
map, the null value is returned.- Parameters:
cBase
- the COSBase for the font container- Returns:
- the font container.
-
getIccProfileWrapper
public ICCProfileWrapper getIccProfileWrapper()
- Returns:
- the iccProfileWrapper
-
setIccProfileWrapper
public void setIccProfileWrapper(ICCProfileWrapper iccProfileWrapper)
- Parameters:
iccProfileWrapper
- the iccProfileWrapper to set
-
getConfig
public PreflightConfiguration getConfig()
-
setConfig
public void setConfig(PreflightConfiguration config)
-
close
public void close()
Close all opened resources- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
-
addValidationError
public void addValidationError(ValidationResult.ValidationError error)
Add the given error the PreflightDocument- Parameters:
error
-
-
addValidationErrors
public void addValidationErrors(java.util.List<ValidationResult.ValidationError> errors)
Add the given errors the PreflightDocument- Parameters:
errors
- the list of validation errors.
-
getValidationPath
public PreflightPath getValidationPath()
-
setValidationPath
public void setValidationPath(PreflightPath validationPath)
-
isIccProfileAlreadySearched
public boolean isIccProfileAlreadySearched()
-
setIccProfileAlreadySearched
public void setIccProfileAlreadySearched(boolean iccProfileAlreadySearched)
-
setCurrentPageNumber
public void setCurrentPageNumber(java.lang.Integer currentPageNumber)
Sets or resets the current page number.- Parameters:
currentPageNumber
- zero based page number or null if none is known.
-
getCurrentPageNumber
public java.lang.Integer getCurrentPageNumber()
Returns the current page number or null if none is known.
-
setFileLen
public void setFileLen(long fileLen)
-
getFileLen
public long getFileLen()
-
addToProcessedSet
public void addToProcessedSet(COSObjectable cos)
Add the argument to the set of processed elements,- Parameters:
cos
-
-
isInProcessedSet
public boolean isInProcessedSet(COSObjectable cos)
Tell if the argument is in the set of processed elements.- Parameters:
cos
-- Returns:
- true if in the set, false if not.
-
-