Class PdfBoxDocumentReader

java.lang.Object
eu.europa.esig.dss.pdf.pdfbox.PdfBoxDocumentReader
All Implemented Interfaces:
Closeable, AutoCloseable

public class PdfBoxDocumentReader extends Object
The PDFBox implementation of PdfDocumentReader
  • Constructor Details

    • PdfBoxDocumentReader

      public PdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument) throws IOException, eu.europa.esig.dss.pades.exception.InvalidPasswordException
      Default constructor of the PDFBox implementation of the Reader. This constructor uses in-memory processing of the document.
      Parameters:
      dssDocument - DSSDocument to read
      Throws:
      IOException - if an exception occurs
      eu.europa.esig.dss.pades.exception.InvalidPasswordException - if the password is not provided or invalid for a protected document
    • PdfBoxDocumentReader

      public PdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument, String passwordProtection) throws IOException, eu.europa.esig.dss.pades.exception.InvalidPasswordException
      Constructor of the PDFBox implementation of the Reader with a password protection phrase provided. This constructor uses in-memory processing of the document.
      Parameters:
      dssDocument - DSSDocument to read
      passwordProtection - String a password to open a protected document
      Throws:
      IOException - if an exception occurs
      eu.europa.esig.dss.pades.exception.InvalidPasswordException - if the password is not provided or invalid for a protected document
    • PdfBoxDocumentReader

      public PdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument, String passwordProtection, eu.europa.esig.dss.pdf.PdfMemoryUsageSetting pdfMemoryUsageSetting) throws IOException, eu.europa.esig.dss.pades.exception.InvalidPasswordException
      Constructor of the PDFBox implementation of the Reader with a password protection phrase and memory usage settings provided.
      Parameters:
      dssDocument - DSSDocument to read
      passwordProtection - String a password to open a protected document
      pdfMemoryUsageSetting - MemoryUsageSetting PDF loading setting
      Throws:
      IOException - if an exception occurs
      eu.europa.esig.dss.pades.exception.InvalidPasswordException - if the password is not provided or invalid for a protected document
  • Method Details

    • getPDDocument

      public org.apache.pdfbox.pdmodel.PDDocument getPDDocument()
      Returns the current instance of PDDocument
      Returns:
      PDDocument
    • getDSSDictionary

      public eu.europa.esig.dss.pdf.PdfDssDict getDSSDictionary()
    • extractSigDictionaries

      public Map<eu.europa.esig.dss.pades.validation.PdfSignatureDictionary, List<eu.europa.esig.dss.pades.validation.PdfSignatureField>> extractSigDictionaries() throws IOException
      Throws:
      IOException
    • isSignatureCoversWholeDocument

      public boolean isSignatureCoversWholeDocument(eu.europa.esig.dss.pades.validation.PdfSignatureDictionary signatureDictionary)
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getNumberOfPages

      public int getNumberOfPages()
    • getPageBox

      public eu.europa.esig.dss.pdf.AnnotationBox getPageBox(int page)
    • getPageRotation

      public int getPageRotation(int page)
    • getPdfAnnotations

      public List<eu.europa.esig.dss.pdf.PdfAnnotation> getPdfAnnotations(int page) throws IOException
      Throws:
      IOException
    • getPDPage

      public org.apache.pdfbox.pdmodel.PDPage getPDPage(int page)
      Returns a PDPage
      Parameters:
      page - number
      Returns:
      PDPage
    • getObjectByKey

      public org.apache.pdfbox.cos.COSObject getObjectByKey(eu.europa.esig.dss.pades.validation.PdfObjectKey objectKey)
      Gets COSObject from the PDF by the given objectKey
      Parameters:
      objectKey - PdfObjectKey to get object for
      Returns:
      COSObject when the object corresponding to the defined key found, NULL otherwise
    • createCOSStream

      public org.apache.pdfbox.cos.COSStream createCOSStream(byte[] binaries)
      Creates a COSStream with given binaries
      Parameters:
      binaries - binary array to be included to the stream
      Returns:
      COSStream
    • generateImageScreenshot

      public BufferedImage generateImageScreenshot(int page) throws IOException
      Throws:
      IOException
    • generateImageScreenshotWithoutAnnotations

      public BufferedImage generateImageScreenshotWithoutAnnotations(int page, List<eu.europa.esig.dss.pdf.PdfAnnotation> annotations) throws IOException
      Throws:
      IOException
    • isEncrypted

      public boolean isEncrypted()
    • isOpenWithOwnerAccess

      public boolean isOpenWithOwnerAccess()
    • canFillSignatureForm

      public boolean canFillSignatureForm()
    • canCreateSignatureField

      public boolean canCreateSignatureField()
    • getCertificationPermission

      public eu.europa.esig.dss.enumerations.CertificationPermission getCertificationPermission()
    • isUsageRightsSignaturePresent

      public boolean isUsageRightsSignaturePresent()
    • getCatalogDictionary

      public eu.europa.esig.dss.pdf.PdfDict getCatalogDictionary()
    • generateDocumentId

      public long generateDocumentId(eu.europa.esig.dss.pades.PAdESCommonParameters parameters)
      Computes a DocumentId in a deterministic way based on the given parameters and the document
      Parameters:
      parameters - PAdESCommonParameters
      Returns:
      deterministic identifier
    • getPdfHeaderVersion

      public float getPdfHeaderVersion()
    • getVersion

      public float getVersion()
    • setVersion

      public void setVersion(float version)
    • createPdfDict

      public eu.europa.esig.dss.pdf.PdfDict createPdfDict()
    • createPdfArray

      public eu.europa.esig.dss.pdf.PdfArray createPdfArray()