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 classPdf20Checker.ParentChildRelationshipHandlerprivate static classPdf20Checker.StructureTreeRootHandlerHandler class that checks structure nodes while traversing the document structure tree.
-
Field Summary
Fields Modifier and Type Field Description private static PdfAllowedTagRelationsallowedTagRelationsprivate static java.util.function.Function<java.lang.String,PdfException>EXCEPTION_SUPPLIERprivate TagStructureContexttagStructureContext
-
Constructor Summary
Constructors Constructor Description Pdf20Checker(PdfDocument pdfDocument)Creates newPdf20Checkerinstance to validate PDF document against PDF 2.0 standard.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckCatalog(PdfCatalog catalog)Validates document catalog dictionary against PDF 2.0 standard.(package private) voidcheckLang(PdfCatalog catalog)Checks that natural language is declared using the methods described in ISO 32000-2:2020, 14.9.2.(package private) voidcheckMetadata(PdfCatalog catalog)Checks that the value of theMetadatakey from theCatalogdictionary of a conforming file is a metadata stream as defined in ISO 32000-2:2020.(package private) voidcheckStructureTreeRoot(PdfStructTreeRoot structTreeRoot)Validates document structure tree root dictionary against PDF 2.0 standard.booleanisPdfObjectReadyToFlush(PdfObject object)IsPdfObjectready to flush.voidvalidate(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 newPdf20Checkerinstance to validate PDF document against PDF 2.0 standard.- Parameters:
pdfDocument-PdfDocumentto check
-
-
Method Detail
-
validate
public void validate(IValidationContext validationContext)
Description copied from interface:IValidationCheckerValidate the providedIValidationContext.- Specified by:
validatein interfaceIValidationChecker- Parameters:
validationContext- theIValidationContextto validate
-
isPdfObjectReadyToFlush
public boolean isPdfObjectReadyToFlush(PdfObject object)
Description copied from interface:IValidationCheckerIsPdfObjectready to flush.- Specified by:
isPdfObjectReadyToFlushin interfaceIValidationChecker- Parameters:
object- the pdf object to check- Returns:
trueif the object is ready to flush,falseotherwise
-
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-PdfCatalogdocument catalog dictionary
-
checkMetadata
void checkMetadata(PdfCatalog catalog)
Checks that the value of theMetadatakey from theCatalogdictionary of a conforming file is a metadata stream as defined in ISO 32000-2:2020.- Parameters:
catalog-PdfCatalogdocument 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-PdfStructTreeRootto validate
-
checkCatalog
private void checkCatalog(PdfCatalog catalog)
Validates document catalog dictionary against PDF 2.0 standard.For now, only
MetadataandLangare checked.- Parameters:
catalog-PdfCatalogdocument catalog dictionary to check
-
-