Package com.logicaldoc.core.util
Class PDFImageExtractor
java.lang.Object
com.logicaldoc.core.util.PDFImageExtractor
- All Implemented Interfaces:
- AutoCloseable
This utility class allows the extraction of raster images from a PDF document
- Since:
- 1.0.0
- Author:
- Marco Meschieri - LogicalDOC
- 
Constructor SummaryConstructorsConstructorDescriptionPDFImageExtractor(File pdfFile) Creates a new PDF reader for the given PDF file
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Closes the PDF and releases resources usedextractImage(int pageIndex, org.apache.pdfbox.cos.COSName imageKey) Extracts the imageKey image from the given pageExtracts all images of the entire documentSet<org.apache.pdfbox.cos.COSName> getImageKeys(int pageIndex) Gets the set of images identifiers inside the given pageintReturns the total number of pages in the PDFgetPageAsImage(int pageIndex) Renders the specified page as a buffered image
- 
Constructor Details- 
PDFImageExtractorCreates a new PDF reader for the given PDF file- Parameters:
- pdfFile- the pdf file
 
 
- 
- 
Method Details- 
closeCloses the PDF and releases resources used- Specified by:
- closein interface- AutoCloseable
- Throws:
- IOException- if the pdf file cannot be read
 
- 
getNumberOfPagespublic int getNumberOfPages()Returns the total number of pages in the PDF- Returns:
- the total number of pages
 
- 
getPageAsImageRenders the specified page as a buffered image- Parameters:
- pageIndex- zero based page index, i.e., the first page is page 0
- Returns:
- object representation of the image
- Throws:
- IOException- if the pdf file cannot be read
 
- 
extractImagepublic BufferedImage extractImage(int pageIndex, org.apache.pdfbox.cos.COSName imageKey) throws IOException Extracts the imageKey image from the given page- Parameters:
- pageIndex- zero based page index, i.e., the first page is page 0
- imageKey- identifier of the image
- Returns:
- object representation of the image
- Throws:
- IOException- if the pdf file cannot be read
 
- 
rotate90SX
- 
getImageKeysGets the set of images identifiers inside the given page- Parameters:
- pageIndex- zero based page index, i.e., the first page is page 0
- Returns:
- set of image identifiers
- Throws:
- IOException- if the pdf file cannot be read
 
- 
extractImagesExtracts all images of the entire document- Returns:
- The list of images
- Throws:
- IOException- if the pdf file cannot be read
 
 
-