Package com.itextpdf.kernel.validation
Class Pdf20Checker
- java.lang.Object
-
- com.itextpdf.kernel.validation.Pdf20Checker
-
- All Implemented Interfaces:
IValidationChecker
public class Pdf20Checker extends java.lang.Object implements IValidationChecker
Class that will run through all necessary checks defined in the PDF 2.0 standard. The standard that is followed is the series of ISO 32000 specifications, starting from ISO 32000-2:2020.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Pdf20Checker.ParentChildRelationshipHandler
private static class
Pdf20Checker.StructureTreeRootHandler
Handler class that checks structure nodes while traversing the document structure tree.
-
Field Summary
Fields Modifier and Type Field Description private static PdfAllowedTagRelations
allowedTagRelations
private static java.util.function.Function<java.lang.String,PdfException>
EXCEPTION_SUPPLIER
private TagStructureContext
tagStructureContext
-
Constructor Summary
Constructors Constructor Description Pdf20Checker(PdfDocument pdfDocument)
Creates newPdf20Checker
instance to validate PDF document against PDF 2.0 standard.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkCatalog(PdfCatalog catalog)
Validates document catalog dictionary against PDF 2.0 standard.(package private) void
checkLang(PdfCatalog catalog)
Checks that natural language is declared using the methods described in ISO 32000-2:2020, 14.9.2.(package private) void
checkMetadata(PdfCatalog catalog)
Checks that the value of theMetadata
key from theCatalog
dictionary of a conforming file is a metadata stream as defined in ISO 32000-2:2020.(package private) void
checkStructureTreeRoot(PdfStructTreeRoot structTreeRoot)
Validates document structure tree root dictionary against PDF 2.0 standard.boolean
isPdfObjectReadyToFlush(PdfObject object)
IsPdfObject
ready to flush.void
validate(IValidationContext validationContext)
Validate the providedIValidationContext
.
-
-
-
Field Detail
-
EXCEPTION_SUPPLIER
private static final java.util.function.Function<java.lang.String,PdfException> EXCEPTION_SUPPLIER
-
allowedTagRelations
private static final PdfAllowedTagRelations allowedTagRelations
-
tagStructureContext
private final TagStructureContext tagStructureContext
-
-
Constructor Detail
-
Pdf20Checker
public Pdf20Checker(PdfDocument pdfDocument)
Creates newPdf20Checker
instance to validate PDF document against PDF 2.0 standard.- Parameters:
pdfDocument
-PdfDocument
to check
-
-
Method Detail
-
validate
public void validate(IValidationContext validationContext)
Description copied from interface:IValidationChecker
Validate the providedIValidationContext
.- Specified by:
validate
in interfaceIValidationChecker
- Parameters:
validationContext
- theIValidationContext
to validate
-
isPdfObjectReadyToFlush
public boolean isPdfObjectReadyToFlush(PdfObject object)
Description copied from interface:IValidationChecker
IsPdfObject
ready to flush.- Specified by:
isPdfObjectReadyToFlush
in interfaceIValidationChecker
- Parameters:
object
- the pdf object to check- Returns:
true
if the object is ready to flush,false
otherwise
-
checkLang
void checkLang(PdfCatalog catalog)
Checks that natural language is declared using the methods described in ISO 32000-2:2020, 14.9.2.- Parameters:
catalog
-PdfCatalog
document catalog dictionary
-
checkMetadata
void checkMetadata(PdfCatalog catalog)
Checks that the value of theMetadata
key from theCatalog
dictionary of a conforming file is a metadata stream as defined in ISO 32000-2:2020.- Parameters:
catalog
-PdfCatalog
document catalog dictionary
-
checkStructureTreeRoot
void checkStructureTreeRoot(PdfStructTreeRoot structTreeRoot)
Validates document structure tree root dictionary against PDF 2.0 standard.Checks, that all structure elements are belong to, or role mapped to (such role mapping may be transitive through other namespaces), at least one of the following namespaces specified in ISO 32000-2:2020, 14.8.6: — the PDF 1.7 namespace; — the PDF 2.0 namespace; — the MathML namespace. A structure element with no explicit namespace may be present. Such a structure element shall have, after any role mapping, a structure type matching one of the unique PDF 1.7 element types (the default standard structure namespace in ISO 32000-2 is defined as the PDF 1.7 namespace).
- Parameters:
structTreeRoot
-PdfStructTreeRoot
to validate
-
checkCatalog
private void checkCatalog(PdfCatalog catalog)
Validates document catalog dictionary against PDF 2.0 standard.For now, only
Metadata
andLang
are checked.- Parameters:
catalog
-PdfCatalog
document catalog dictionary to check
-
-