Package com.itextpdf.pdfa.checker
Class PdfAChecker
java.lang.Object
com.itextpdf.pdfa.checker.PdfAChecker
- Direct Known Subclasses:
-
PdfA1Checker
An abstract class that will run through all necessary checks defined in the different PDF/A standards and levels. A number of common checks are executed in this class, while standard-dependent specifications are implemented in the available subclasses. The standard that is followed is the series of ISO 19005 specifications, currently generations 1 through 3. The ZUGFeRD standard is derived from ISO 19005-3. While it is possible to subclass this method and implement its abstract methods in client code, this is not encouraged and will have little effect. It is not possible to plug custom implementations into iText, because iText should always refuse to create non-compliant PDF/A, which would be possible with client code implementations. Any future generations of the PDF/A standard and its derivates will get their own implementation in the iText 7 - pdfa project.
-
Field Summary
Modifier and TypeFieldDescriptionContains some objects that are already checked.protected Map<PdfObject,
PdfColorSpace> protected boolean
protected PdfAConformanceLevel
protected boolean
protected int
static final String
The Cyan-Magenta-Yellow-Key (black) color profile as defined by the International Color Consortium.static final String
The Grayscale color profile as defined by the International Color Consortium.static final String
The Red-Green-Blue color profile as defined by the International Color Consortium.static final String
The Monitor device classstatic final String
The Output device classstatic final int
The maximum Graphics State stack depth in PDF/A documents, i.e.protected String
protected boolean
-
Constructor Summary
ModifierConstructorDescriptionprotected
PdfAChecker
(PdfAConformanceLevel conformanceLevel) Creates a PdfAChecker with the required conformance level. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
checkAction
(PdfDictionary action) Checks if the action is allowed.protected abstract void
checkAnnotation
(PdfDictionary annotDic) Verify the conformity of the annotation dictionary.protected void
checkAppearanceStream
(PdfStream appearanceStream) Check single annotation appearance stream.abstract void
checkCanvasStack
(char stackOperation) This method checks compliance with the graphics state architectural limitation, explained bymaxGsStackDepth
.protected abstract void
checkCatalogValidEntries
(PdfDictionary catalogDict) Checks if entries in catalog dictionary are valid.abstract void
checkColor
(Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream) This method checks compliance with the color restrictions imposed by the available color spaces in the document.abstract void
checkColorSpace
(PdfColorSpace colorSpace, PdfDictionary currentColorSpaces, boolean checkAlternate, Boolean fill) This method performs a range of checks on the given color space, depending on the type and properties of that color space.protected abstract void
Verify the conformity of used color spaces.protected abstract void
checkContentStream
(PdfStream contentStream) Attest content stream conformance with appropriate specification.protected abstract void
checkContentStreamObject
(PdfObject object) Verify the conformity of the operand of content stream with appropriate specification.void
checkDocument
(PdfCatalog catalog) This method checks a number of document-wide requirements of the PDF/A standard.abstract void
checkExtGState
(CanvasGraphicsState extGState, PdfStream contentStream) Performs a number of checks on the graphics state, among others ISO 19005-1 section 6.2.8 and 6.4 and ISO 19005-2 section 6.2.5 and 6.2.10.protected abstract void
checkFileSpec
(PdfDictionary fileSpec) Verify the conformity of the file specification dictionary.protected static boolean
checkFlag
(int flags, int flag) Checks if the specified flag is set.abstract void
Performs a number of checks on the font.abstract void
checkFontGlyphs
(PdfFont font, PdfStream contentStream) Performs a check of the each font glyph as a Form XObject.protected abstract void
checkForm
(PdfDictionary form) Verify the conformity of the form dictionary.protected abstract void
checkFormXObject
(PdfStream form) Verify the conformity of the form XObject dictionary.protected abstract void
checkImage
(PdfStream image, PdfDictionary currentColorSpaces) Verify the conformity of the given image.abstract void
checkInlineImage
(PdfStream inlineImage, PdfDictionary currentColorSpaces) This method checks compliance with the inline image restrictions in the PDF/A specs, specifically filter parameters.protected abstract void
checkLogicalStructure
(PdfDictionary catalog) Performs a number of checks on the logical structure of the document.protected abstract void
checkMetaData
(PdfDictionary catalog) Performs a number of checks on the metadata of the document.protected abstract void
checkNonSymbolicTrueTypeFont
(PdfTrueTypeFont trueTypeFont) Verify the conformity of the non-symbolic TrueType font.protected abstract void
checkOutputIntents
(PdfDictionary catalog) Verify the conformity of the output intents array in the catalog dictionary.protected abstract void
checkPageObject
(PdfDictionary page, PdfDictionary pageResources) Verify the conformity of the page dictionary.protected abstract void
checkPageSize
(PdfDictionary page) Checks the allowable size of the page.protected abstract void
checkPageTransparency
(PdfDictionary pageDict, PdfDictionary pageResources) Verify the conformity of the page transparency.protected abstract void
checkPdfArray
(PdfArray array) Verify the conformity of the PDF array.protected abstract void
checkPdfDictionary
(PdfDictionary dictionary) Verify the conformity of the PDF dictionary.protected abstract void
checkPdfName
(PdfName name) Verify the conformity of the PDF name.protected abstract void
checkPdfNumber
(PdfNumber number) Verify the conformity of the PDF number.void
checkPdfObject
(PdfObject obj) This method checks the requirements that must be fulfilled by a COS object in a PDF/A document.protected abstract void
checkPdfStream
(PdfStream stream) Verify the conformity of the PDF stream.protected abstract void
checkPdfString
(PdfString string) Verify the conformity of the PDF string.abstract void
checkRenderingIntent
(PdfName intent) Checks whether the rendering intent of the document is within the allowed range of intents.protected void
checkResources
(PdfDictionary resources) Verify the conformity of the resources dictionary.protected void
checkResourcesOfAppearanceStreams
(PdfDictionary appearanceStreamsDict) Checks resources of the appearance streams.void
checkSignature
(PdfDictionary signatureDict) This method checks compliance of the signature dictionaryvoid
checkSinglePage
(PdfPage page) This method checks all requirements that must be fulfilled by a page in a PDF/A document.protected static boolean
checkStructure
(PdfAConformanceLevel conformanceLevel) Checks conformance level of PDF/A standard.protected abstract void
checkSymbolicTrueTypeFont
(PdfTrueTypeFont trueTypeFont) Verify the conformity of the symbolic TrueType font.void
This method checks compliance of the tag structure elements, such as struct elements or parent tree entries.protected abstract void
checkTrailer
(PdfDictionary trailer) Verify the conformity of the trailer dictionary.abstract void
checkXrefTable
(PdfXrefTable xrefTable) Verify the conformity of the cross-reference table.Retrieve allowed actions in conforming document.Gets thePdfAConformanceLevel
for this file.Retrieve forbidden actions in conforming document.protected abstract long
Retrieve maximum allowed number of indirect objects in conforming document.protected boolean
isAlreadyChecked
(PdfDictionary dictionary) Checks whether the specified dictionary was already checked.protected static boolean
isContainsTransparencyGroup
(PdfDictionary dictionary) Checks whether the specified dictionary has a transparency group.boolean
In full check mode all objects will be tested for ISO conformance.boolean
objectIsChecked
(PdfObject object) Remembers which objects have already been checked, in order to avoid redundant checks.void
setFullCheckMode
(boolean fullCheckMode) In full check mode all objects will be tested for ISO conformance.
-
Field Details
-
ICC_COLOR_SPACE_RGB
The Red-Green-Blue color profile as defined by the International Color Consortium.- See Also:
-
ICC_COLOR_SPACE_CMYK
The Cyan-Magenta-Yellow-Key (black) color profile as defined by the International Color Consortium.- See Also:
-
ICC_COLOR_SPACE_GRAY
The Grayscale color profile as defined by the International Color Consortium.- See Also:
-
ICC_DEVICE_CLASS_OUTPUT_PROFILE
The Output device class- See Also:
-
ICC_DEVICE_CLASS_MONITOR_PROFILE
The Monitor device class- See Also:
-
maxGsStackDepth
public static final int maxGsStackDepthThe maximum Graphics State stack depth in PDF/A documents, i.e. the maximum number of graphics state operators with codeq
that may be opened (i.e. not yet closed by a correspondingQ
) at any point in a content stream sequence. Defined as 28 by PDF/A-1 section 6.1.12, by referring to the PDF spec Appendix C table 1 "architectural limits".- See Also:
-
conformanceLevel
-
pdfAOutputIntentColorSpace
-
gsStackDepth
protected int gsStackDepth -
rgbIsUsed
protected boolean rgbIsUsed -
cmykIsUsed
protected boolean cmykIsUsed -
grayIsUsed
protected boolean grayIsUsed -
checkedObjects
Contains some objects that are already checked. NOTE: Not all objects that were checked are stored in that set. This set is used for avoiding double checks for actions, signatures, xObjects and page objects; and for letting those objects to be manually flushed. Use this mechanism carefully: objects that are able to be changed (or at least if object's properties that shall be checked are able to be changed) shouldn't be marked as checked if they are not to be flushed immediately. -
checkedObjectsColorspace
-
-
Constructor Details
-
PdfAChecker
Creates a PdfAChecker with the required conformance level.- Parameters:
-
conformanceLevel
- the required conformance level
-
-
Method Details
-
checkDocument
This method checks a number of document-wide requirements of the PDF/A standard. The algorithms of some of these checks vary with the PDF/A level and thus are implemented in subclasses; others are implemented as private methods in this class.- Parameters:
-
catalog
- The catalog being checked
-
checkSinglePage
This method checks all requirements that must be fulfilled by a page in a PDF/A document.- Parameters:
-
page
- the page that must be checked
-
checkPdfObject
This method checks the requirements that must be fulfilled by a COS object in a PDF/A document.- Parameters:
-
obj
- the COS object that must be checked
-
getConformanceLevel
Gets thePdfAConformanceLevel
for this file.- Returns:
- the defined conformance level for this document.
-
isFullCheckMode
public boolean isFullCheckMode()In full check mode all objects will be tested for ISO conformance. If full check mode is switched off objects which were not modified might be skipped to speed up the validation of the document- Returns:
- true if full check mode is switched on
- See Also:
-
setFullCheckMode
public void setFullCheckMode(boolean fullCheckMode) In full check mode all objects will be tested for ISO conformance. If full check mode is switched off objects which were not modified might be skipped to speed up the validation of the document- Parameters:
-
fullCheckMode
- is a new value for full check mode switcher - See Also:
-
objectIsChecked
Remembers which objects have already been checked, in order to avoid redundant checks.- Parameters:
-
object
- the object to check - Returns:
- whether or not the object has already been checked
-
checkTagStructureElement
This method checks compliance of the tag structure elements, such as struct elements or parent tree entries.- Parameters:
-
obj
- an object that represents tag structure element.
-
checkSignature
This method checks compliance of the signature dictionary- Parameters:
-
signatureDict
- aPdfDictionary
containing the signature.
-
checkCanvasStack
public abstract void checkCanvasStack(char stackOperation) This method checks compliance with the graphics state architectural limitation, explained bymaxGsStackDepth
.- Parameters:
-
stackOperation
- the operation to check the graphics state counter for
-
checkInlineImage
This method checks compliance with the inline image restrictions in the PDF/A specs, specifically filter parameters.- Parameters:
-
inlineImage
- aPdfStream
containing the inline image -
currentColorSpaces
- aPdfDictionary
containing the color spaces used in the document
-
checkColor
public abstract void checkColor(Color color, PdfDictionary currentColorSpaces, Boolean fill, PdfStream contentStream) This method checks compliance with the color restrictions imposed by the available color spaces in the document. This method will be abstract in update 7.2- Parameters:
-
color
- the color to check -
currentColorSpaces
- aPdfDictionary
containing the color spaces used in the document -
fill
- whether the color is used for fill or stroke operations -
contentStream
- current content stream
-
checkColorSpace
public abstract void checkColorSpace(PdfColorSpace colorSpace, PdfDictionary currentColorSpaces, boolean checkAlternate, Boolean fill) This method performs a range of checks on the given color space, depending on the type and properties of that color space.- Parameters:
-
colorSpace
- the color space to check -
currentColorSpaces
- aPdfDictionary
containing the color spaces used in the document -
checkAlternate
- whether or not to also check the parent color space -
fill
- whether the color space is used for fill or stroke operations
-
checkRenderingIntent
Checks whether the rendering intent of the document is within the allowed range of intents. This is defined in ISO 19005-1 section 6.2.9, and unchanged in newer generations of the PDF/A specification.- Parameters:
-
intent
- the intent to be analyzed
-
checkFontGlyphs
Performs a check of the each font glyph as a Form XObject. See ISO 19005-2 Annex A.5. This only applies to type 3 fonts. This method will be abstract in update 7.2- Parameters:
-
font
-PdfFont
to be checked -
contentStream
- stream containing checked font
-
checkExtGState
Performs a number of checks on the graphics state, among others ISO 19005-1 section 6.2.8 and 6.4 and ISO 19005-2 section 6.2.5 and 6.2.10. This method will be abstract in the update 7.2- Parameters:
-
extGState
- the graphics state to be checked -
contentStream
- current content stream
-
checkFont
Performs a number of checks on the font. See ISO 19005-1 section 6.3, ISO 19005-2 and ISO 19005-3 section 6.2.11. Be aware that not all constraints defined in the ISO are checked in this method, for most of them we consider that iText always creates valid fonts.- Parameters:
-
pdfFont
- font to be checked
-
checkXrefTable
Verify the conformity of the cross-reference table.- Parameters:
-
xrefTable
- is the Xref table
-
checkContentStream
Attest content stream conformance with appropriate specification. Throws PdfAConformanceException if any discrepancy was found- Parameters:
-
contentStream
- is a content stream to validate
-
checkContentStreamObject
Verify the conformity of the operand of content stream with appropriate specification. Throws PdfAConformanceException if any discrepancy was found- Parameters:
-
object
- is an operand of content stream to validate
-
getMaxNumberOfIndirectObjects
protected abstract long getMaxNumberOfIndirectObjects()Retrieve maximum allowed number of indirect objects in conforming document.- Returns:
- maximum allowed number of indirect objects
-
getForbiddenActions
Retrieve forbidden actions in conforming document.- Returns:
-
set of
PdfName
with forbidden actions
-
getAllowedNamedActions
Retrieve allowed actions in conforming document.- Returns:
-
set of
PdfName
with allowed named actions
-
checkAction
Checks if the action is allowed.- Parameters:
-
action
- to be checked
-
checkAnnotation
Verify the conformity of the annotation dictionary.- Parameters:
-
annotDic
- the annotationPdfDictionary
to be checked
-
checkCatalogValidEntries
Checks if entries in catalog dictionary are valid.- Parameters:
-
catalogDict
- the catalogPdfDictionary
to be checked
-
checkColorsUsages
protected abstract void checkColorsUsages()Verify the conformity of used color spaces. -
checkImage
Verify the conformity of the given image.- Parameters:
-
image
- the image to check -
currentColorSpaces
- thePdfDictionary
containing the color spaces used in the document
-
checkFileSpec
Verify the conformity of the file specification dictionary.- Parameters:
-
fileSpec
- thePdfDictionary
containing file specification to be checked
-
checkForm
Verify the conformity of the form dictionary.- Parameters:
-
form
- the formPdfDictionary
to be checked
-
checkFormXObject
Verify the conformity of the form XObject dictionary.- Parameters:
-
form
- thePdfStream
to check
-
checkLogicalStructure
Performs a number of checks on the logical structure of the document.- Parameters:
-
catalog
- the catalogPdfDictionary
to check
-
checkMetaData
Performs a number of checks on the metadata of the document.- Parameters:
-
catalog
- the catalogPdfDictionary
to check
-
checkNonSymbolicTrueTypeFont
Verify the conformity of the non-symbolic TrueType font.- Parameters:
-
trueTypeFont
- thePdfTrueTypeFont
to check
-
checkOutputIntents
Verify the conformity of the output intents array in the catalog dictionary.- Parameters:
-
catalog
- thePdfDictionary
to check
-
checkPageObject
Verify the conformity of the page dictionary.- Parameters:
-
page
- thePdfDictionary
to check -
pageResources
- the page's resources dictionary
-
checkPageSize
Checks the allowable size of the page.- Parameters:
-
page
- thePdfDictionary
of page which size being checked
-
checkPdfArray
Verify the conformity of the PDF array.- Parameters:
-
array
- thePdfArray
to check
-
checkPdfDictionary
Verify the conformity of the PDF dictionary.- Parameters:
-
dictionary
- thePdfDictionary
to check
-
checkPdfName
Verify the conformity of the PDF name.- Parameters:
-
name
- thePdfName
to check
-
checkPdfNumber
Verify the conformity of the PDF number.- Parameters:
-
number
- thePdfNumber
to check
-
checkPdfStream
Verify the conformity of the PDF stream.- Parameters:
-
stream
- thePdfStream
to check
-
checkPdfString
Verify the conformity of the PDF string.- Parameters:
-
string
- thePdfString
to check
-
checkSymbolicTrueTypeFont
Verify the conformity of the symbolic TrueType font.- Parameters:
-
trueTypeFont
- thePdfTrueTypeFont
to check
-
checkTrailer
Verify the conformity of the trailer dictionary.- Parameters:
-
trailer
- thePdfDictionary
of trailer to check
-
checkPageTransparency
Verify the conformity of the page transparency.- Parameters:
-
pageDict
- thePdfDictionary
contains contents for transparency to be checked -
pageResources
- thePdfDictionary
contains resources for transparency to be checked
-
checkResources
Verify the conformity of the resources dictionary.- Parameters:
-
resources
- thePdfDictionary
to be checked
-
checkFlag
protected static boolean checkFlag(int flags, int flag) Checks if the specified flag is set.- Parameters:
-
flags
- a set of flags specifying various characteristics of the PDF object -
flag
- to be checked - Returns:
- true if the specified flag is set
-
checkStructure
Checks conformance level of PDF/A standard.- Parameters:
-
conformanceLevel
- thePdfAConformanceLevel
to be checked - Returns:
-
true if the specified conformanceLevel is
a
for PDF/A-1, PDF/A-2 or PDF/A-3
-
isContainsTransparencyGroup
Checks whether the specified dictionary has a transparency group.- Parameters:
-
dictionary
- thePdfDictionary
to check - Returns:
-
true if and only if the specified dictionary has a
PdfName.Group
key and its value is a dictionary withPdfName.Transparency
subtype
-
isAlreadyChecked
Checks whether the specified dictionary was already checked.- Parameters:
-
dictionary
- thePdfDictionary
to check - Returns:
- true if the specified dictionary was checked
-
checkResourcesOfAppearanceStreams
Checks resources of the appearance streams.- Parameters:
-
appearanceStreamsDict
- the dictionary with appearance streams to check.
-
checkAppearanceStream
Check single annotation appearance stream.- Parameters:
-
appearanceStream
- thePdfStream
to check
-