Package eu.europa.esig.dss.pdf
Interface PdfDocumentReader
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Implementing Classes:
ITextDocumentReader
,PdfBoxDocumentReader
Reads the PDF Document
-
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 dictionaryCreates an emptyPdfArray
Creates an emptyPdfDict
Extracts PdfSignatureDictionaries present in the signaturegenerateImageScreenshot
(int page) Generates the image screenshot for the given page of the PDFgenerateImageScreenshotWithoutAnnotations
(int page, List<PdfAnnotation> addedAnnotations) 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.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
-
Method Details
-
getDSSDictionary
PdfDssDict getDSSDictionary()Loads the last DSS dictionary from the document if exists NOTE: can return null if DSS dictionary is not present- Returns:
PdfDssDict
-
extractSigDictionaries
Extracts PdfSignatureDictionaries present in the signature- Returns:
- a map between
PdfSignatureDictionary
and relatedPdfSignatureField
s - Throws:
IOException
- if an exception occurs
-
isSignatureCoversWholeDocument
Checks if a signature for the given PDF Signature Dictionary covers the whole document- Parameters:
signatureDictionary
-PdfSignatureDictionary
to check the result for- Returns:
- TRUE if the signature covers the whole document, false otherwise
-
getNumberOfPages
int getNumberOfPages()Returns an amount of pages found in the document- Returns:
- number of pages
-
getPageBox
Returns a page box dimensions- Parameters:
page
- number of a page to get annotation box of- Returns:
AnnotationBox
representing page dimensions
-
getPageRotation
int getPageRotation(int page) This method returns a corresponding page's rotation within the document- Parameters:
page
- number of a page to get rotation of- Returns:
- rotation degrees
-
getPdfAnnotations
Retrieves all annotations found in the document- Parameters:
page
- number- Returns:
- a list of
PdfAnnotation
s associated with the given page - Throws:
IOException
- if an exception occurs
-
generateImageScreenshot
Generates the image screenshot for the given page of the PDF- Parameters:
page
- number to be generated- Returns:
BufferedImage
screenshot for the given page- Throws:
IOException
- if an exception occurs
-
generateImageScreenshotWithoutAnnotations
BufferedImage generateImageScreenshotWithoutAnnotations(int page, List<PdfAnnotation> addedAnnotations) throws IOException Generates the image screenshot by hiding the given list ofannotationBoxes
- Parameters:
page
- number to be generatedaddedAnnotations
- a list ofPdfAnnotation
s to be hidden- Returns:
BufferedImage
screenshot for the given page- Throws:
IOException
- if an exception occurs
-
isEncrypted
boolean isEncrypted()This method checks whether the document is encrypted- Returns:
- TRUE if the document is encrypted, FALSE otherwise
-
isOpenWithOwnerAccess
boolean isOpenWithOwnerAccess()This method verifies if the document has been opened with a full owner access (all modifications are permitted)- Returns:
- TRUE if the document has been open with a full access, FALSE otherwise
-
canFillSignatureForm
boolean canFillSignatureForm()This method verifies whether fill-in of existing signature fields is allowed by PDF document permissions dictionary- Returns:
- TRUE if fill-in signature forms is permitted, FALSE otherwise
-
canCreateSignatureField
boolean canCreateSignatureField()This method verifies whether creation of new signature fields is allowed by the PDF permissions dictionary- Returns:
- TRUE if the new signature field creation is permitted, FALSE otherwise
-
getCertificationPermission
CertificationPermission getCertificationPermission()Returns value of /DocMDP dictionary defining the permitted modification in a PDF, when present- Returns:
CertificationPermission
-
isUsageRightsSignaturePresent
boolean isUsageRightsSignaturePresent()This method verifies whether a PDF contains a usage rights signature- Returns:
- TRUE of a PDF contains a usage rights signature, FALSE otherwise
-
getCatalogDictionary
-
getPdfHeaderVersion
float getPdfHeaderVersion()Returns version of the PDF document defined in the document's header.- Returns:
- document version from file's header
-
getVersion
float getVersion()Returns version of the PDF document. Returns version defined in the file header, or catalog's /Version, when latest is present.- Returns:
- document version
-
setVersion
void setVersion(float version) Sets PDF version number, by upgrading /Catalog dictionary /Version parameter- Parameters:
version
- value (e.g. 1.7)
-
createPdfDict
-
createPdfArray
-