Package eu.europa.esig.dss.pdf.pdfbox
Class PdfBoxDocumentReader
java.lang.Object
eu.europa.esig.dss.pdf.pdfbox.PdfBoxDocumentReader
- All Implemented Interfaces:
PdfDocumentReader,Closeable,AutoCloseable
public class PdfBoxDocumentReader extends Object implements PdfDocumentReader
The PDFBox implementation of
PdfDocumentReader-
Constructor Summary
Constructors Constructor Description PdfBoxDocumentReader(byte[] binaries, String passwordProtection)The PDFBox implementation of the ReaderPdfBoxDocumentReader(DSSDocument dssDocument)Default constructor of the PDFBox implementation of the ReaderPdfBoxDocumentReader(DSSDocument dssDocument, String passwordProtection)The PDFBox implementation of the ReaderPdfBoxDocumentReader(org.apache.pdfbox.pdmodel.PDDocument pdDocument)The constructor to directly instantiate thePdfBoxDocumentReader -
Method Summary
Modifier and Type Method Description voidclose()Map<PdfSignatureDictionary,List<String>>extractSigDictionaries()Extracts PdfSignatureDictionaries present in the signatureBufferedImagegenerateImageScreenshot(int page)Generates the image screenshot for the given page of the PDFBufferedImagegenerateImageScreenshotWithoutAnnotations(int page, List<PdfAnnotation> annotations)Generates the image screenshot by hiding the given list ofannotationBoxesPdfDssDictgetDSSDictionary()Loads the last DSS dictionary from the document if exists NOTE: can return null if DSS dictionary is not presentintgetNumberOfPages()Returns an amount of pages found in the documentAnnotationBoxgetPageBox(int page)Returns a page box dimensionsList<PdfAnnotation>getPdfAnnotations(int page)Retrieves all annotations found in the documentorg.apache.pdfbox.pdmodel.PDPagegetPDPage(int page)Returns aPDPagebooleanisSignatureCoversWholeDocument(PdfSignatureDictionary signatureDictionary)Checks if a signature for the given PDF Signature Dictionary covers the whole document
-
Constructor Details
-
PdfBoxDocumentReader
Default constructor of the PDFBox 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
-
PdfBoxDocumentReader
public PdfBoxDocumentReader(DSSDocument dssDocument, String passwordProtection) throws IOException, InvalidPasswordExceptionThe PDFBox implementation of the Reader- Parameters:
dssDocument-DSSDocumentto readpasswordProtection-Stringa password to open a protected document- Throws:
IOException- if an exception occursInvalidPasswordException- if the password is not provided or invalid for a protected document
-
PdfBoxDocumentReader
public PdfBoxDocumentReader(byte[] binaries, String passwordProtection) throws IOException, InvalidPasswordExceptionThe PDFBox implementation of the Reader- Parameters:
binaries- a byte array of a PDF to readpasswordProtection-Stringa password to open a protected document- Throws:
IOException- if an exception occursInvalidPasswordException- if the password is not provided or invalid for a protected document
-
PdfBoxDocumentReader
public PdfBoxDocumentReader(org.apache.pdfbox.pdmodel.PDDocument pdDocument)The constructor to directly instantiate thePdfBoxDocumentReader- Parameters:
pdDocument-PDDocument
-
-
Method Details
-
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 related field names - Throws:
IOException- if an exception occurs
-
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
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
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- Returns:
AnnotationBoxrepresenting page dimensions
-
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 - Throws:
IOException- if an exception occurs
-
getPDPage
public org.apache.pdfbox.pdmodel.PDPage getPDPage(int page)Returns aPDPage- Parameters:
page- number- Returns:
PDPage
-
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- Throws:
IOException- if an exception occurs
-
generateImageScreenshotWithoutAnnotations
public BufferedImage generateImageScreenshotWithoutAnnotations(int page, List<PdfAnnotation> annotations) throws IOExceptionDescription 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- Throws:
IOException- if an exception occurs
-