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
ConstructorsConstructorDescriptionITextDocumentReader(byte[] binaries, byte[] passwordProtection) The OpenPDF implementation of the ReaderITextDocumentReader(com.lowagie.text.pdf.PdfReader pdfReader) The constructor to directly instantiate theITextDocumentReaderITextDocumentReader(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 TypeMethodDescriptionvoidThis method checks if the document is not encrypted or with limited edition rightsvoidclose()Extracts PdfSignatureDictionaries present in the signaturegenerateImageScreenshot(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 ofannotationBoxesReturns 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 presentintReturns an amount of pages found in the documentgetPageBox(int page) Returns a page box dimensionsintgetPageRotation(int page) This method returns a corresponding page's rotation within the documentgetPdfAnnotations(int page) Retrieves all annotations found in the documentcom.lowagie.text.pdf.PdfReaderReturns the current instance ofPdfReaderbooleanisSignatureCoversWholeDocument(PdfSignatureDictionary signatureDictionary) Checks if a signature for the given PDF Signature Dictionary covers the whole documentbooleanThis method verifies whether a PDF contains a usage rights signature
-
Constructor Details
-
ITextDocumentReader
Default constructor of the OpenPDF implementation of the Reader- Parameters:
dssDocument-DSSDocumentto 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-DSSDocumentto 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:PdfDocumentReaderLoads the last DSS dictionary from the document if exists NOTE: can return null if DSS dictionary is not present- Specified by:
getDSSDictionaryin interfacePdfDocumentReader- Returns:
PdfDssDict
-
extractSigDictionaries
Description copied from interface:PdfDocumentReaderExtracts PdfSignatureDictionaries present in the signature- Specified by:
extractSigDictionariesin interfacePdfDocumentReader- Returns:
- a map between
PdfSignatureDictionaryand relatedPdfSignatureFields
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isSignatureCoversWholeDocument
Description copied from interface:PdfDocumentReaderChecks if a signature for the given PDF Signature Dictionary covers the whole document- Specified by:
isSignatureCoversWholeDocumentin interfacePdfDocumentReader- Parameters:
signatureDictionary-PdfSignatureDictionaryto check the result for- Returns:
- TRUE if the signature covers the whole document, false otherwise
-
getNumberOfPages
public int getNumberOfPages()Description copied from interface:PdfDocumentReaderReturns an amount of pages found in the document- Specified by:
getNumberOfPagesin interfacePdfDocumentReader- Returns:
- number of pages
-
getPageBox
Description copied from interface:PdfDocumentReaderReturns a page box dimensions- Specified by:
getPageBoxin interfacePdfDocumentReader- Parameters:
page- number of a page to get annotation box of- Returns:
AnnotationBoxrepresenting page dimensions
-
getPageRotation
public int getPageRotation(int page) Description copied from interface:PdfDocumentReaderThis method returns a corresponding page's rotation within the document- Specified by:
getPageRotationin interfacePdfDocumentReader- Parameters:
page- number of a page to get rotation of- Returns:
- rotation degrees
-
getPdfAnnotations
Description copied from interface:PdfDocumentReaderRetrieves all annotations found in the document- Specified by:
getPdfAnnotationsin interfacePdfDocumentReader- Parameters:
page- number- Returns:
- a list of
PdfAnnotations associated with the given page
-
generateImageScreenshot
Description copied from interface:PdfDocumentReaderGenerates the image screenshot for the given page of the PDF- Specified by:
generateImageScreenshotin interfacePdfDocumentReader- Parameters:
page- number to be generated- Returns:
BufferedImagescreenshot for the given page
-
generateImageScreenshotWithoutAnnotations
public BufferedImage generateImageScreenshotWithoutAnnotations(int page, List<PdfAnnotation> annotations) Description copied from interface:PdfDocumentReaderGenerates the image screenshot by hiding the given list ofannotationBoxes- Specified by:
generateImageScreenshotWithoutAnnotationsin interfacePdfDocumentReader- Parameters:
page- number to be generatedannotations- a list ofPdfAnnotations to be hidden- Returns:
BufferedImagescreenshot for the given page
-
checkDocumentPermissions
public void checkDocumentPermissions()Description copied from interface:PdfDocumentReaderThis method checks if the document is not encrypted or with limited edition rights- Specified by:
checkDocumentPermissionsin interfacePdfDocumentReader
-
getCertificationPermission
Description copied from interface:PdfDocumentReaderReturns value of /DocMDP dictionary defining the permitted modification in a PDF, when present- Specified by:
getCertificationPermissionin interfacePdfDocumentReader- Returns:
CertificationPermission
-
isUsageRightsSignaturePresent
public boolean isUsageRightsSignaturePresent()Description copied from interface:PdfDocumentReaderThis method verifies whether a PDF contains a usage rights signature- Specified by:
isUsageRightsSignaturePresentin interfacePdfDocumentReader- Returns:
- TRUE of a PDF contains a usage rights signature, FALSE otherwise
-
getCatalogDictionary
Description copied from interface:PdfDocumentReaderReturns a document catalog as a dictionary- Specified by:
getCatalogDictionaryin interfacePdfDocumentReader- Returns:
PdfDict
-