Package eu.europa.esig.dss.pdf.openpdf
Class ITextDocumentReader
java.lang.Object
eu.europa.esig.dss.pdf.openpdf.ITextDocumentReader
- All Implemented Interfaces:
PdfDocumentReader
,Closeable
,AutoCloseable
The IText (OpenPdf) implementation of
PdfDocumentReader
-
Constructor Summary
ConstructorDescriptionITextDocumentReader
(byte[] binaries, byte[] passwordProtection) The OpenPDF implementation of the ReaderITextDocumentReader
(com.lowagie.text.pdf.PdfReader pdfReader) The constructor to directly instantiate theITextDocumentReader
ITextDocumentReader
(DSSDocument dssDocument) Default constructor of the OpenPDF implementation of the ReaderITextDocumentReader
(DSSDocument dssDocument, byte[] passwordProtection) The OpenPDF implementation of the Reader -
Method Summary
Modifier and TypeMethodDescriptionboolean
This method verifies whether creation of new signature fields is allowed by the PDF permissions dictionaryboolean
This method verifies whether fill-in of existing signature fields is allowed by PDF document permissions dictionaryvoid
close()
Creates an emptyPdfArray
Creates an emptyPdfDict
Extracts PdfSignatureDictionaries present in the signaturecom.lowagie.text.pdf.PdfObject
generateDocumentId
(PAdESCommonParameters parameters) Computes a DocumentId in a deterministic way based on the givenparameters
and the documentgenerateImageScreenshot
(int page) Generates the image screenshot for the given page of the PDFgenerateImageScreenshotWithoutAnnotations
(int page, List<PdfAnnotation> annotations) Generates the image screenshot by hiding the given list ofannotationBoxes
Returns a document catalog as a dictionaryReturns value of /DocMDP dictionary defining the permitted modification in a PDF, when presentLoads the last DSS dictionary from the document if exists NOTE: can return null if DSS dictionary is not presentint
Returns an amount of pages found in the documentgetPageBox
(int page) Returns a page box dimensionsint
getPageRotation
(int page) This method returns a corresponding page's rotation within the documentgetPdfAnnotations
(int page) Retrieves all annotations found in the documentfloat
Returns version of the PDF document defined in the document's header.com.lowagie.text.pdf.PdfReader
Returns the current instance ofPdfReader
float
Returns version of the PDF document.boolean
This method checks whether the document is encryptedboolean
This method verifies if the document has been opened with a full owner access (all modifications are permitted)boolean
isSignatureCoversWholeDocument
(PdfSignatureDictionary signatureDictionary) Checks if a signature for the given PDF Signature Dictionary covers the whole documentboolean
This method verifies whether a PDF contains a usage rights signaturevoid
setVersion
(float version) Sets PDF version number, by upgrading /Catalog dictionary /Version parameter
-
Constructor Details
-
ITextDocumentReader
Default constructor of the OpenPDF implementation of the Reader- Parameters:
dssDocument
-DSSDocument
to read- Throws:
IOException
- if an exception occursInvalidPasswordException
- if the password is not provided or invalid for a protected document
-
ITextDocumentReader
public ITextDocumentReader(DSSDocument dssDocument, byte[] passwordProtection) throws IOException, InvalidPasswordException The OpenPDF implementation of the Reader- Parameters:
dssDocument
-DSSDocument
to readpasswordProtection
- binaries of a password to open a protected document- Throws:
IOException
- if an exception occursInvalidPasswordException
- if the password is not provided or invalid for a protected document
-
ITextDocumentReader
public ITextDocumentReader(byte[] binaries, byte[] passwordProtection) throws IOException, InvalidPasswordException The OpenPDF implementation of the Reader- Parameters:
binaries
- a byte array of a PDF to readpasswordProtection
- binaries of a password to open a protected document- Throws:
IOException
- if an exception occursInvalidPasswordException
- if the password is not provided or invalid for a protected document
-
ITextDocumentReader
public ITextDocumentReader(com.lowagie.text.pdf.PdfReader pdfReader) The constructor to directly instantiate theITextDocumentReader
- Parameters:
pdfReader
-PdfReader
-
-
Method Details
-
getPdfReader
public com.lowagie.text.pdf.PdfReader getPdfReader()Returns the current instance ofPdfReader
- Returns:
PdfReader
-
getDSSDictionary
Description copied from interface:PdfDocumentReader
Loads the last DSS dictionary from the document if exists NOTE: can return null if DSS dictionary is not present- Specified by:
getDSSDictionary
in interfacePdfDocumentReader
- Returns:
PdfDssDict
-
extractSigDictionaries
Description copied from interface:PdfDocumentReader
Extracts PdfSignatureDictionaries present in the signature- Specified by:
extractSigDictionaries
in interfacePdfDocumentReader
- Returns:
- a map between
PdfSignatureDictionary
and relatedPdfSignatureField
s
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
isSignatureCoversWholeDocument
Description copied from interface:PdfDocumentReader
Checks if a signature for the given PDF Signature Dictionary covers the whole document- Specified by:
isSignatureCoversWholeDocument
in interfacePdfDocumentReader
- Parameters:
signatureDictionary
-PdfSignatureDictionary
to check the result for- Returns:
- TRUE if the signature covers the whole document, false otherwise
-
getNumberOfPages
public int getNumberOfPages()Description copied from interface:PdfDocumentReader
Returns an amount of pages found in the document- Specified by:
getNumberOfPages
in interfacePdfDocumentReader
- Returns:
- number of pages
-
getPageBox
Description copied from interface:PdfDocumentReader
Returns a page box dimensions- Specified by:
getPageBox
in interfacePdfDocumentReader
- Parameters:
page
- number of a page to get annotation box of- Returns:
AnnotationBox
representing page dimensions
-
getPageRotation
public int getPageRotation(int page) Description copied from interface:PdfDocumentReader
This method returns a corresponding page's rotation within the document- Specified by:
getPageRotation
in interfacePdfDocumentReader
- Parameters:
page
- number of a page to get rotation of- Returns:
- rotation degrees
-
getPdfAnnotations
Description copied from interface:PdfDocumentReader
Retrieves all annotations found in the document- Specified by:
getPdfAnnotations
in interfacePdfDocumentReader
- Parameters:
page
- number- Returns:
- a list of
PdfAnnotation
s associated with the given page
-
generateImageScreenshot
Description copied from interface:PdfDocumentReader
Generates the image screenshot for the given page of the PDF- Specified by:
generateImageScreenshot
in interfacePdfDocumentReader
- Parameters:
page
- number to be generated- Returns:
BufferedImage
screenshot for the given page
-
generateImageScreenshotWithoutAnnotations
public BufferedImage generateImageScreenshotWithoutAnnotations(int page, List<PdfAnnotation> annotations) Description copied from interface:PdfDocumentReader
Generates the image screenshot by hiding the given list ofannotationBoxes
- Specified by:
generateImageScreenshotWithoutAnnotations
in interfacePdfDocumentReader
- Parameters:
page
- number to be generatedannotations
- a list ofPdfAnnotation
s to be hidden- Returns:
BufferedImage
screenshot for the given page
-
isEncrypted
public boolean isEncrypted()Description copied from interface:PdfDocumentReader
This method checks whether the document is encrypted- Specified by:
isEncrypted
in interfacePdfDocumentReader
- Returns:
- TRUE if the document is encrypted, FALSE otherwise
-
isOpenWithOwnerAccess
public boolean isOpenWithOwnerAccess()Description copied from interface:PdfDocumentReader
This method verifies if the document has been opened with a full owner access (all modifications are permitted)- Specified by:
isOpenWithOwnerAccess
in interfacePdfDocumentReader
- Returns:
- TRUE if the document has been open with a full access, FALSE otherwise
-
canFillSignatureForm
public boolean canFillSignatureForm()Description copied from interface:PdfDocumentReader
This method verifies whether fill-in of existing signature fields is allowed by PDF document permissions dictionary- Specified by:
canFillSignatureForm
in interfacePdfDocumentReader
- Returns:
- TRUE if fill-in signature forms is permitted, FALSE otherwise
-
canCreateSignatureField
public boolean canCreateSignatureField()Description copied from interface:PdfDocumentReader
This method verifies whether creation of new signature fields is allowed by the PDF permissions dictionary- Specified by:
canCreateSignatureField
in interfacePdfDocumentReader
- Returns:
- TRUE if the new signature field creation is permitted, FALSE otherwise
-
getCertificationPermission
Description copied from interface:PdfDocumentReader
Returns value of /DocMDP dictionary defining the permitted modification in a PDF, when present- Specified by:
getCertificationPermission
in interfacePdfDocumentReader
- Returns:
CertificationPermission
-
isUsageRightsSignaturePresent
public boolean isUsageRightsSignaturePresent()Description copied from interface:PdfDocumentReader
This method verifies whether a PDF contains a usage rights signature- Specified by:
isUsageRightsSignaturePresent
in interfacePdfDocumentReader
- Returns:
- TRUE of a PDF contains a usage rights signature, FALSE otherwise
-
getCatalogDictionary
Description copied from interface:PdfDocumentReader
Returns a document catalog as a dictionary- Specified by:
getCatalogDictionary
in interfacePdfDocumentReader
- Returns:
PdfDict
-
generateDocumentId
Computes a DocumentId in a deterministic way based on the givenparameters
and the document- Parameters:
parameters
-PAdESCommonParameters
- Returns:
PdfObject
representing an /ID entry containing a deterministic identifier
-
getPdfHeaderVersion
public float getPdfHeaderVersion()Description copied from interface:PdfDocumentReader
Returns version of the PDF document defined in the document's header.- Specified by:
getPdfHeaderVersion
in interfacePdfDocumentReader
- Returns:
- document version from file's header
-
getVersion
public float getVersion()Description copied from interface:PdfDocumentReader
Returns version of the PDF document. Returns version defined in the file header, or catalog's /Version, when latest is present.- Specified by:
getVersion
in interfacePdfDocumentReader
- Returns:
- document version
-
setVersion
public void setVersion(float version) Description copied from interface:PdfDocumentReader
Sets PDF version number, by upgrading /Catalog dictionary /Version parameter- Specified by:
setVersion
in interfacePdfDocumentReader
- Parameters:
version
- value (e.g. 1.7)
-
createPdfDict
Description copied from interface:PdfDocumentReader
Creates an emptyPdfDict
- Specified by:
createPdfDict
in interfacePdfDocumentReader
- Returns:
PdfDict
-
createPdfArray
Description copied from interface:PdfDocumentReader
Creates an emptyPdfArray
- Specified by:
createPdfArray
in interfacePdfDocumentReader
- Returns:
PdfArray
-