Package com.itextpdf.pdfua.checkers
Class PdfUAChecker
- java.lang.Object
-
- com.itextpdf.pdfua.checkers.PdfUAChecker
-
- All Implemented Interfaces:
IValidationChecker
- Direct Known Subclasses:
PdfUA1Checker
,PdfUA2Checker
public abstract class PdfUAChecker extends java.lang.Object implements IValidationChecker
An abstract class that will run through all necessary checks defined in the different PDF/UA standards. 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 14289 specifications, currently generations 1 and 2.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/UA, which would be possible with client code implementations. Any future generations of the PDF/UA standard and its derivatives will get their own implementation in the iText - pdfua project.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
PdfUAChecker.UaCharacterChecker
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.util.function.Function<java.lang.String,PdfException>
EXCEPTION_SUPPLIER
private boolean
warnedOnPageFlush
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdfUAChecker()
Creates newPdfUAChecker
instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) void
checkContentInCanvas(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack, PdfDocument document)
Checks if content is neither marked as Artifact nor tagged as real content.(package private) void
checkFonts(java.util.Collection<PdfFont> fontsInDocument)
Checks that font programs for all fonts used for rendering within a conforming file, as determined by whether at least one of its glyphs is referenced from one or more content streams, are embedded within that file, as defined in ISO 32000-2:2020, 9.9 and ISO 32000-1:2008, 9.9.(package private) void
checkLang(PdfCatalog catalog)
Checks that the default natural language for content and text strings is specified using theLang
entry, with a nonempty value, in the document catalog dictionary.(package private) void
checkLogicalStructureInBMC(java.util.Stack<Tuple2<PdfName,PdfDictionary>> stack, Tuple2<PdfName,PdfDictionary> currentBmc, PdfDocument document)
Checks if content marked as Artifact resides in Artifact content, but real content does not.(package private) abstract void
checkNonSymbolicCmapSubtable(TrueTypeFont fontProgram)
Checks cmap entries present in the embedded TrueType font program of the non-symbolic TrueType font.private void
checkNonSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont)
private static void
checkOCGNameAndASKey(PdfDictionary dict)
(package private) void
checkOCProperties(PdfDictionary ocProperties)
Checks that all optional content configuration dictionaries in the file, including the default one, shall contain a Name entry (see ISO 32000-2:2020, Table 96, or ISO 32000-1:2008, 8.11.2.1, Table 98) whose value is a non-empty text string when document contains a Configs entry in the OCProperties entry of the document catalog dictionary (see ISO 32000-2:2020, Table 29, or ISO 32000-1:2008, 7.7.2, Table 28), and the Configs entry contains at least one optional content configuration dictionary.(package private) abstract void
checkSymbolicCmapSubtable(TrueTypeFont fontProgram)
Checks cmap entries present in the embedded TrueType font program of the symbolic TrueType font.private void
checkSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont)
(package private) void
checkText(java.lang.String str, PdfFont font)
Checks that embedded fonts define all glyphs referenced for rendering within the conforming file.(package private) void
checkViewerPreferences(PdfCatalog catalog)
Checks that theViewerPreferences
dictionary of the document catalog dictionary is present and contains at least theDisplayDocTitle
key with a value oftrue
, as defined in ISO 32000-1:2008, 12.2, Table 150 or ISO 32000-2:2020, Table 147.private static boolean
isInsideArtifact(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack)
private static boolean
isInsideRealContent(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack, PdfDocument document)
private static boolean
isRealContent(Tuple2<PdfName,PdfDictionary> tag, PdfDocument document)
private static PdfMcr
mcrExists(PdfDocument document, int mcid)
void
warnOnPageFlush()
Logs a warn on page flushing that page flushing is disabled in PDF/UA mode.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.itextpdf.kernel.validation.IValidationChecker
isPdfObjectReadyToFlush, validate
-
-
-
-
Field Detail
-
EXCEPTION_SUPPLIER
static final java.util.function.Function<java.lang.String,PdfException> EXCEPTION_SUPPLIER
-
warnedOnPageFlush
private boolean warnedOnPageFlush
-
-
Constructor Detail
-
PdfUAChecker
protected PdfUAChecker()
Creates newPdfUAChecker
instance.
-
-
Method Detail
-
warnOnPageFlush
public void warnOnPageFlush()
Logs a warn on page flushing that page flushing is disabled in PDF/UA mode.
-
checkLang
void checkLang(PdfCatalog catalog)
Checks that the default natural language for content and text strings is specified using theLang
entry, with a nonempty value, in the document catalog dictionary.- Parameters:
catalog
-PdfCatalog
document catalog dictionary
-
checkViewerPreferences
void checkViewerPreferences(PdfCatalog catalog)
Checks that theViewerPreferences
dictionary of the document catalog dictionary is present and contains at least theDisplayDocTitle
key with a value oftrue
, as defined in ISO 32000-1:2008, 12.2, Table 150 or ISO 32000-2:2020, Table 147.- Parameters:
catalog
-PdfCatalog
document catalog dictionary
-
checkOCProperties
void checkOCProperties(PdfDictionary ocProperties)
Checks that all optional content configuration dictionaries in the file, including the default one, shall contain a Name entry (see ISO 32000-2:2020, Table 96, or ISO 32000-1:2008, 8.11.2.1, Table 98) whose value is a non-empty text string when document contains a Configs entry in the OCProperties entry of the document catalog dictionary (see ISO 32000-2:2020, Table 29, or ISO 32000-1:2008, 7.7.2, Table 28), and the Configs entry contains at least one optional content configuration dictionary.Also checks that the AS key does not appear in any optional content configuration dictionary.
- Parameters:
ocProperties
- OCProperties entry of the Catalog dictionary
-
checkLogicalStructureInBMC
void checkLogicalStructureInBMC(java.util.Stack<Tuple2<PdfName,PdfDictionary>> stack, Tuple2<PdfName,PdfDictionary> currentBmc, PdfDocument document)
Checks if content marked as Artifact resides in Artifact content, but real content does not.- Parameters:
stack
- the tag structure stackcurrentBmc
- the current BMCdocument
-PdfDocument
to check
-
checkContentInCanvas
void checkContentInCanvas(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack, PdfDocument document)
Checks if content is neither marked as Artifact nor tagged as real content.- Parameters:
tagStack
- tag structure stackdocument
-PdfDocument
to check
-
checkFonts
void checkFonts(java.util.Collection<PdfFont> fontsInDocument)
Checks that font programs for all fonts used for rendering within a conforming file, as determined by whether at least one of its glyphs is referenced from one or more content streams, are embedded within that file, as defined in ISO 32000-2:2020, 9.9 and ISO 32000-1:2008, 9.9.Checks character encodings rules as defined in ISO 14289-2, 8.4.5.7 and ISO 14289-1, 7.21.6.
- Parameters:
fontsInDocument
- collection of fonts used in the document
-
checkNonSymbolicCmapSubtable
abstract void checkNonSymbolicCmapSubtable(TrueTypeFont fontProgram)
Checks cmap entries present in the embedded TrueType font program of the non-symbolic TrueType font.- Parameters:
fontProgram
- the embedded TrueType font program to check
-
checkSymbolicCmapSubtable
abstract void checkSymbolicCmapSubtable(TrueTypeFont fontProgram)
Checks cmap entries present in the embedded TrueType font program of the symbolic TrueType font.- Parameters:
fontProgram
- the embedded TrueType font program to check
-
checkText
void checkText(java.lang.String str, PdfFont font)
Checks that embedded fonts define all glyphs referenced for rendering within the conforming file.- Parameters:
str
- the text to checkfont
- the font to check
-
checkOCGNameAndASKey
private static void checkOCGNameAndASKey(PdfDictionary dict)
-
isInsideArtifact
private static boolean isInsideArtifact(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack)
-
isInsideRealContent
private static boolean isInsideRealContent(java.util.Stack<Tuple2<PdfName,PdfDictionary>> tagStack, PdfDocument document)
-
isRealContent
private static boolean isRealContent(Tuple2<PdfName,PdfDictionary> tag, PdfDocument document)
-
mcrExists
private static PdfMcr mcrExists(PdfDocument document, int mcid)
-
checkNonSymbolicTrueTypeFont
private void checkNonSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont)
-
checkSymbolicTrueTypeFont
private void checkSymbolicTrueTypeFont(PdfTrueTypeFont trueTypeFont)
-
-