java.lang.Object
com._4point.testing.matchers.aem.Pdf
All Implemented Interfaces:
AutoCloseable

public class Pdf extends Object implements AutoCloseable
An object representing a PDF that can be queried about its properties.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Exceptions specific to PDF Processing
    static class 
    Runtime exceptions specific to PDF Processing
    static class 
    Represents Usage Rights (granted to this PDF by Reader Extensions or Acrobat)
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a list of the fonts use by the Pdf
    void
     
    Returns a list of the fonts embedded in the Pdf
    static Pdf
    from(byte[] docBytes)
    Static factory that creates a Pdf object from a byte array.
    static Pdf
    from(InputStream docStream)
    Static factory that creates a Pdf object from an InputStream.
    static Pdf
    from(Path docPath)
    Static factory that creates a Pdf object from a file on the file system.
    Retrieves the usage rights from the Pdf
    boolean
    Checks whether this Pdf has usage rights assigned (via Reader Extensions or Acrobat)
    boolean
    Checks whether this Pdf has an XFA section
    boolean
    Checks whether this Pdf is a dynamic Pdf
    boolean
    Checks whether this Pdf is an interactive Pdf
    boolean
    Checks whether this Pdf contains Tags

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isDynamic

      public boolean isDynamic()
      Checks whether this Pdf is a dynamic Pdf
      Returns:
      true if this Pdf is a dynamic Pdf, false if this Pdf is a static Pdf
    • isInteractive

      public boolean isInteractive()
      Checks whether this Pdf is an interactive Pdf
      Returns:
      true if this Pdf is an interactive Pdf, false if non-interactive
    • hasXfa

      public boolean hasXfa()
      Checks whether this Pdf has an XFA section
      Returns:
      true if this Pdf is an XFA Pdf, otherwise false
    • hasRights

      public boolean hasRights()
      Checks whether this Pdf has usage rights assigned (via Reader Extensions or Acrobat)
      Returns:
      true if this Pdf has usage rights assigned.
    • isTagged

      public boolean isTagged()
      Checks whether this Pdf contains Tags
      Returns:
      true if Pdf contains tags, otherwise false
    • allFonts

      public List<String> allFonts() throws Pdf.PdfException
      Returns a list of the fonts use by the Pdf
      Returns:
      the fonts
      Throws:
      Pdf.PdfException - thrown if errors occur when parsing the Pdf
    • embeddedFonts

      public List<String> embeddedFonts() throws Pdf.PdfException
      Returns a list of the fonts embedded in the Pdf
      Returns:
      the embedded fonts
      Throws:
      Pdf.PdfException - thrown if errors occur when parsing the Pdf
    • getUsageRights

      public Pdf.UsageRights getUsageRights()
      Retrieves the usage rights from the Pdf
      Returns:
      the rights
    • from

      public static Pdf from(byte[] docBytes) throws Pdf.PdfException
      Static factory that creates a Pdf object from a byte array.
      Parameters:
      docBytes - bytes containing a complete Pdf document
      Returns:
      the Pdf object
      Throws:
      Pdf.PdfException - thrown if there are errors parsing the Pdf bytes
    • from

      public static Pdf from(InputStream docStream) throws Pdf.PdfException
      Static factory that creates a Pdf object from an InputStream.
      Parameters:
      docStream - Pdf byte stream
      Returns:
      the Pdf object
      Throws:
      Pdf.PdfException - thrown if there are errors reading the Pdf byte stream
    • from

      public static Pdf from(Path docPath) throws Pdf.PdfException
      Static factory that creates a Pdf object from a file on the file system.
      Parameters:
      docPath - location of Pdf file
      Returns:
      the Pdf object
      Throws:
      Pdf.PdfException - thrown if there are errors reading the Pdf file
    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception