Class PdfCheckersUtil


  • public final class PdfCheckersUtil
    extends java.lang.Object
    Utility class that contains common checks used in both PDF/A and PDF/UA modules.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private PdfCheckersUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean checkFlag​(int flags, int flag)
      Checks if the specified flag is set.
      static void checkMetadata​(PdfDictionary catalog, PdfConformance conformance, java.util.function.Function<java.lang.String,​PdfException> exceptionSupplier)
      Checks that the Catalog dictionary of a conforming file contains the Metadata key whose value is a metadata stream as defined in ISO 32000-2:2020.
      static PdfArray getFormFields​(PdfArray array)
      Gets all the descending kids including widgets for a given PdfArray representing array of form fields.
      private static boolean isValidXmpRevision​(java.lang.String value)
      Validates pdfuaid:rev value which is four-digit year of the date of publication or revision.
      static void validateLang​(PdfDictionary catalogDict, java.util.function.Function<java.lang.String,​PdfException> exceptionSupplier)
      Checks that natural language is declared using the methods described in ISO 32000-2:2020, 14.9.2 or ISO 32000-1:2008, 14.9.2 (same requirements).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PdfCheckersUtil

        private PdfCheckersUtil()
    • Method Detail

      • validateLang

        public static void validateLang​(PdfDictionary catalogDict,
                                        java.util.function.Function<java.lang.String,​PdfException> exceptionSupplier)
        Checks that natural language is declared using the methods described in ISO 32000-2:2020, 14.9.2 or ISO 32000-1:2008, 14.9.2 (same requirements).
        Parameters:
        catalogDict - PdfDictionary document catalog dictionary containing Lang entry to check
        exceptionSupplier - Function<String, PdfException> in order to provide correct exception
      • checkMetadata

        public static void checkMetadata​(PdfDictionary catalog,
                                         PdfConformance conformance,
                                         java.util.function.Function<java.lang.String,​PdfException> exceptionSupplier)
        Checks that the Catalog dictionary of a conforming file contains the Metadata key whose value is a metadata stream as defined in ISO 32000-2:2020. Also checks that the value of either pdfuaid:part or pdfaid:part is the provided one for conforming PDF files and validates required pdfuaid:rev or pdfaid:rev value.

        For PDF/UA, checks that the Metadata stream as specified in ISO 32000-2:2020, 14.3 in the document catalog dictionary includes a dc:title entry reflecting the title of the document.

        For PDF/A, checks that pdfa:conformance value is correct if specified.

        Parameters:
        catalog - PdfDictionary document catalog dictionary
        conformance - either PDF/A or PDF/UA conformance to check
        exceptionSupplier - Function<String, PdfException> in order to provide correct exception
      • getFormFields

        public static PdfArray getFormFields​(PdfArray array)
        Gets all the descending kids including widgets for a given PdfArray representing array of form fields.
        Parameters:
        array - the PdfArray of form fields PdfDictionary objects
        Returns:
        the PdfArray of all form fields
      • isValidXmpRevision

        private static boolean isValidXmpRevision​(java.lang.String value)
        Validates pdfuaid:rev value which is four-digit year of the date of publication or revision.
        Parameters:
        value - pdfuaid:rev value to check
        Returns:
        true if pdfuaid:rev value is valid, false otherwise
      • checkFlag

        public 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, false otherwise