Package org.apache.pdfbox.util
Class PDFImageWriter
java.lang.Object
org.apache.pdfbox.util.PDFStreamEngine
org.apache.pdfbox.util.PDFImageWriter
This class writes single pages of a pdf to a file.
- Author:
- Daniel Wilson
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate a new PDFImageWriter object.PDFImageWriter
(Properties props) Instantiate a new PDFImageWriter object. -
Method Summary
Modifier and TypeMethodDescriptionboolean
writeImage
(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix) Converts a given page range of a PDF document to bitmap images by callingwriteImage(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix, int imageType, int resolution)
with imageTypeBufferedImage
.TYPE_INT_RGB and screen resolution, or 96dpi if screen resolution is unavailable.boolean
writeImage
(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix, int imageType, int resolution) Converts a given page range of a PDF document to bitmap images.Methods inherited from class org.apache.pdfbox.util.PDFStreamEngine
getColorSpaces, getCurrentPage, getFonts, getGraphicsStack, getGraphicsState, getGraphicsStates, getResources, getTextLineMatrix, getTextMatrix, getTotalCharCnt, getValidCharCnt, getXObjects, inspectFontEncoding, isForceParsing, processEncodedText, processOperator, processOperator, processStream, processSubStream, processTextPosition, registerOperatorProcessor, resetEngine, setColorSpaces, setFonts, setForceParsing, setGraphicsStack, setGraphicsState, setGraphicsStates, setTextLineMatrix, setTextMatrix
-
Constructor Details
-
PDFImageWriter
public PDFImageWriter()Instantiate a new PDFImageWriter object. -
PDFImageWriter
Instantiate a new PDFImageWriter object. Loading all of the operator mappings from the properties object that is passed in.- Parameters:
props
- The properties containing the mapping of operators to PDFOperator classes.- Throws:
IOException
- If there is an error reading the properties.
-
-
Method Details
-
writeImage
public boolean writeImage(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix) throws IOException Converts a given page range of a PDF document to bitmap images by callingwriteImage(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix, int imageType, int resolution)
with imageTypeBufferedImage
.TYPE_INT_RGB and screen resolution, or 96dpi if screen resolution is unavailable.- Parameters:
document
- the PDF documentimageFormat
- the target format (ex. "png")password
- the password (needed if the PDF is encrypted)startPage
- the start page (1 is the first page)endPage
- the end page (set to Integer.MAX_VALUE for all pages)outputPrefix
- used to construct the filename for the individual images- Returns:
- true if the images were produced, false if there was an error
- Throws:
IOException
- if an I/O error occurs
-
writeImage
public boolean writeImage(PDDocument document, String imageFormat, String password, int startPage, int endPage, String outputPrefix, int imageType, int resolution) throws IOException Converts a given page range of a PDF document to bitmap images.- Parameters:
document
- the PDF documentimageFormat
- the target format (ex. "png")password
- the password (needed if the PDF is encrypted)startPage
- the start page (1 is the first page)endPage
- the end page (set to Integer.MAX_VALUE for all pages)outputPrefix
- used to construct the filename for the individual imagesimageType
- the image type (seeBufferedImage
.TYPE_*)resolution
- the resolution in dpi (dots per inch)- Returns:
- true if the images were produced, false if there was an error
- Throws:
IOException
- if an I/O error occurs
-