Package org.jpedal.examples.images
Class ConvertPagesToHiResImages
java.lang.Object
org.jpedal.examples.images.ConvertPagesToHiResImages
Image Extraction from PDF files
This class provides a simple Java API to convert pages in a PDF files into images and also a static convenience method if you just want to dump all the pages as images from a PDF file or directory containing PDF files
See our Support Page for Examples on Convert PDF pages to Images
There is a simpler example (org.jpedal.examples.images.ConvertPagesToImages) for producing images of pages if extra features not needed
-
Constructor Summary
ConstructorDescriptionConvertPagesToHiResImages
(byte[] byteArray) Sets up an ConvertPagesToHiResImages instance to open a PDF file contained as a BLOB within a byte[] streamConvertPagesToHiResImages
(String fileName) Sets up an ConvertPagesToHiResImages instance to open a PDF File -
Method Summary
Modifier and TypeMethodDescriptionvoid
ensure PDF file is closed once no longer needed and all resources releasedgetPageAsHiResImage
(int page, boolean isTransparent, Map<Integer, Object> options) int
number of pages in PDF file (starting at 1)static void
boolean
routine to open the PDF File so we can access - needs to be checked as will be false if file cannot be opened for any reasonvoid
setPassword
(String password) sets the Owner or User Password to use when opening encrypted PDF filestatic void
writeAllPagesAsHiResImagesToDir
(String inputDir, String outputDir, String format) static method to write out all pages in a PDF files or directory of PDF files as images Not for use with other image conversion methods in multi-threaded environments.static void
writeAllPagesAsHiResImagesToDir
(String inputDir, String outputDir, String format, Map<Integer, Object> mapValues) static method to write out all pages in a PDF files or directory of PDF files as images Not for use with other image conversion methods in multi-threaded environments.
-
Constructor Details
-
ConvertPagesToHiResImages
Sets up an ConvertPagesToHiResImages instance to open a PDF File- Parameters:
fileName
- full path to a single PDF file
-
ConvertPagesToHiResImages
public ConvertPagesToHiResImages(byte[] byteArray) Sets up an ConvertPagesToHiResImages instance to open a PDF file contained as a BLOB within a byte[] stream- Parameters:
byteArray
- pdf file data
-
-
Method Details
-
main
-
writeAllPagesAsHiResImagesToDir
public static void writeAllPagesAsHiResImagesToDir(String inputDir, String outputDir, String format) throws PdfException static method to write out all pages in a PDF files or directory of PDF files as images Not for use with other image conversion methods in multi-threaded environments. This method utilises some variables that may impact image conversion taking place on other threads.- Parameters:
inputDir
- directory of files to convertoutputDir
- directory of outputformat
- format of images- Throws:
PdfException
- PdfException
-
writeAllPagesAsHiResImagesToDir
public static void writeAllPagesAsHiResImagesToDir(String inputDir, String outputDir, String format, Map<Integer, Object> mapValues) throws PdfExceptionstatic method to write out all pages in a PDF files or directory of PDF files as images Not for use with other image conversion methods in multi-threaded environments. This method utilises some variables that may impact image conversion taking place on other threads.- Parameters:
inputDir
- directory of files to convertoutputDir
- directory of outputformat
- format of imagesmapValues
- Map of KeyPair values from JPedalSettings- Throws:
PdfException
- PdfException
-
getPageAsHiResImage
public BufferedImage getPageAsHiResImage(int page, boolean isTransparent, Map<Integer, Object> options) throws PdfException- Throws:
PdfException
-
setPassword
sets the Owner or User Password to use when opening encrypted PDF file- Parameters:
password
- the USER or OWNER password for the PDF file
-
getPageCount
public int getPageCount()number of pages in PDF file (starting at 1)- Returns:
- page count
-
openPDFFile
routine to open the PDF File so we can access - needs to be checked as will be false if file cannot be opened for any reason- Returns:
- true if successful
- Throws:
PdfException
- is problem opening file
-
closePDFfile
public void closePDFfile()ensure PDF file is closed once no longer needed and all resources released
-