Class PdfBoxDocumentReader
java.lang.Object
eu.europa.esig.dss.pdf.pdfbox.PdfBoxDocumentReader
- All Implemented Interfaces:
Closeable, AutoCloseable
The PDFBox implementation of
PdfDocumentReader-
Constructor Summary
ConstructorsConstructorDescriptionPdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument) Default constructor of the PDFBox implementation of the Reader.PdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument, String passwordProtection) Constructor of the PDFBox implementation of the Reader with a password protection phrase provided.PdfBoxDocumentReader(eu.europa.esig.dss.model.DSSDocument dssDocument, String passwordProtection, eu.europa.esig.dss.pdf.PdfMemoryUsageSetting pdfMemoryUsageSetting) Constructor of the PDFBox implementation of the Reader with a password protection phrase and memory usage settings provided. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanvoidclose()org.apache.pdfbox.cos.COSStreamcreateCOSStream(byte[] binaries) Creates aCOSStreamwith givenbinarieseu.europa.esig.dss.pdf.PdfArrayeu.europa.esig.dss.pdf.PdfDictMap<eu.europa.esig.dss.pades.validation.PdfSignatureDictionary, List<eu.europa.esig.dss.pades.validation.PdfSignatureField>> longgenerateDocumentId(eu.europa.esig.dss.pades.PAdESCommonParameters parameters) Computes a DocumentId in a deterministic way based on the givenparametersand the documentgenerateImageScreenshot(int page) generateImageScreenshotWithoutAnnotations(int page, List<eu.europa.esig.dss.pdf.PdfAnnotation> annotations) eu.europa.esig.dss.pdf.PdfDicteu.europa.esig.dss.enumerations.CertificationPermissioneu.europa.esig.dss.pdf.PdfDssDictintorg.apache.pdfbox.cos.COSObjectgetObjectByKey(eu.europa.esig.dss.pades.validation.PdfObjectKey objectKey) GetsCOSObjectfrom the PDF by the givenobjectKeyeu.europa.esig.dss.pdf.AnnotationBoxgetPageBox(int page) intgetPageRotation(int page) org.apache.pdfbox.pdmodel.PDDocumentReturns the current instance ofPDDocumentList<eu.europa.esig.dss.pdf.PdfAnnotation> getPdfAnnotations(int page) floatorg.apache.pdfbox.pdmodel.PDPagegetPDPage(int page) Returns aPDPagefloatbooleanbooleanbooleanisSignatureCoversWholeDocument(eu.europa.esig.dss.pades.validation.PdfSignatureDictionary signatureDictionary) booleanvoidsetVersion(float version)
-
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-DSSDocumentto read- Throws:
IOException- if an exception occurseu.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-DSSDocumentto readpasswordProtection-Stringa password to open a protected document- Throws:
IOException- if an exception occurseu.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-DSSDocumentto readpasswordProtection-Stringa password to open a protected documentpdfMemoryUsageSetting-MemoryUsageSettingPDF loading setting- Throws:
IOException- if an exception occurseu.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 ofPDDocument- 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
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
getNumberOfPages
public int getNumberOfPages() -
getPageBox
public eu.europa.esig.dss.pdf.AnnotationBox getPageBox(int page) -
getPageRotation
public int getPageRotation(int page) -
getPdfAnnotations
- Throws:
IOException
-
getPDPage
public org.apache.pdfbox.pdmodel.PDPage getPDPage(int page) Returns aPDPage- Parameters:
page- number- Returns:
PDPage
-
getObjectByKey
public org.apache.pdfbox.cos.COSObject getObjectByKey(eu.europa.esig.dss.pades.validation.PdfObjectKey objectKey) GetsCOSObjectfrom the PDF by the givenobjectKey- Parameters:
objectKey-PdfObjectKeyto get object for- Returns:
COSObjectwhen the object corresponding to the defined key found, NULL otherwise
-
createCOSStream
public org.apache.pdfbox.cos.COSStream createCOSStream(byte[] binaries) Creates aCOSStreamwith givenbinaries- Parameters:
binaries- binary array to be included to the stream- Returns:
COSStream
-
generateImageScreenshot
- 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 givenparametersand 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()
-