public class PDFRenderer extends Object
Modifier and Type | Field and Description |
---|---|
protected PDDocument |
document |
Constructor and Description |
---|
PDFRenderer(PDDocument document)
Creates a new PDFRenderer.
|
Modifier and Type | Method and Description |
---|---|
protected PageDrawer |
createPageDrawer(PageDrawerParameters parameters)
Returns a new PageDrawer instance, using the given parameters.
|
AnnotationFilter |
getAnnotationsFilter()
Return the AnnotationFilter.
|
RenderDestination |
getDefaultDestination() |
float |
getImageDownscalingOptimizationThreshold() |
RenderingHints |
getRenderingHints()
Get the rendering hints.
|
boolean |
isGroupEnabled(PDOptionalContentGroup group)
Indicates whether an optional content group is enabled.
|
boolean |
isSubsamplingAllowed()
Value indicating if the renderer is allowed to subsample images before drawing, according to
image dimensions and requested scale.
|
BufferedImage |
renderImage(int pageIndex)
Returns the given page as an RGB image at 72 DPI
|
BufferedImage |
renderImage(int pageIndex,
float scale)
Returns the given page as an RGB image at the given scale.
|
BufferedImage |
renderImage(int pageIndex,
float scale,
ImageType imageType)
Returns the given page as an RGB or ARGB image at the given scale.
|
BufferedImage |
renderImage(int pageIndex,
float scale,
ImageType imageType,
RenderDestination destination)
Returns the given page as an RGB or ARGB image at the given scale.
|
BufferedImage |
renderImageWithDPI(int pageIndex,
float dpi)
Returns the given page as an RGB image at the given DPI.
|
BufferedImage |
renderImageWithDPI(int pageIndex,
float dpi,
ImageType imageType)
Returns the given page as an RGB image at the given DPI.
|
void |
renderPageToGraphics(int pageIndex,
Graphics2D graphics)
Renders a given page to an AWT Graphics2D instance at 72 DPI.
|
void |
renderPageToGraphics(int pageIndex,
Graphics2D graphics,
float scale)
Renders a given page to an AWT Graphics2D instance.
|
void |
renderPageToGraphics(int pageIndex,
Graphics2D graphics,
float scaleX,
float scaleY)
Renders a given page to an AWT Graphics2D instance.
|
void |
renderPageToGraphics(int pageIndex,
Graphics2D graphics,
float scaleX,
float scaleY,
RenderDestination destination)
Renders a given page to an AWT Graphics2D instance.
|
void |
setAnnotationsFilter(AnnotationFilter annotationsFilter)
Set the AnnotationFilter.
|
void |
setDefaultDestination(RenderDestination defaultDestination) |
void |
setImageDownscalingOptimizationThreshold(float imageDownscalingOptimizationThreshold)
Set the image downscaling optimization threshold.
|
void |
setRenderingHints(RenderingHints renderingHints)
Set the rendering hints.
|
void |
setSubsamplingAllowed(boolean subsamplingAllowed)
Sets a value instructing the renderer whether it is allowed to subsample images before
drawing.
|
protected final PDDocument document
public PDFRenderer(PDDocument document)
document
- the document to renderpublic AnnotationFilter getAnnotationsFilter()
public void setAnnotationsFilter(AnnotationFilter annotationsFilter)
Allows to only render annotation accepted by the filter.
annotationsFilter
- the AnnotationFilterpublic boolean isSubsamplingAllowed()
public void setSubsamplingAllowed(boolean subsamplingAllowed)
subsamplingAllowed
- The new value indicating if subsampling is allowed.public RenderDestination getDefaultDestination()
public void setDefaultDestination(RenderDestination defaultDestination)
defaultDestination
- the defaultDestination to setpublic RenderingHints getRenderingHints()
public void setRenderingHints(RenderingHints renderingHints)
renderingHints
- public float getImageDownscalingOptimizationThreshold()
getImageDownscalingOptimizationThreshold()
for details.public void setImageDownscalingOptimizationThreshold(float imageDownscalingOptimizationThreshold)
imageDownscalingOptimizationThreshold
- public BufferedImage renderImage(int pageIndex) throws IOException
pageIndex
- the zero-based index of the page to be converted.IOException
- if the PDF cannot be readpublic BufferedImage renderImage(int pageIndex, float scale) throws IOException
pageIndex
- the zero-based index of the page to be convertedscale
- the scaling factor, where 1 = 72 DPIIOException
- if the PDF cannot be readpublic BufferedImage renderImageWithDPI(int pageIndex, float dpi) throws IOException
pageIndex
- the zero-based index of the page to be converteddpi
- the DPI (dots per inch) to render atIOException
- if the PDF cannot be readpublic BufferedImage renderImageWithDPI(int pageIndex, float dpi, ImageType imageType) throws IOException
pageIndex
- the zero-based index of the page to be converteddpi
- the DPI (dots per inch) to render atimageType
- the type of image to returnIOException
- if the PDF cannot be readpublic BufferedImage renderImage(int pageIndex, float scale, ImageType imageType) throws IOException
pageIndex
- the zero-based index of the page to be convertedscale
- the scaling factor, where 1 = 72 DPIimageType
- the type of image to returnIOException
- if the PDF cannot be readpublic BufferedImage renderImage(int pageIndex, float scale, ImageType imageType, RenderDestination destination) throws IOException
pageIndex
- the zero-based index of the page to be convertedscale
- the scaling factor, where 1 = 72 DPIimageType
- the type of image to returndestination
- controlling visibility of optional content groupsIOException
- if the PDF cannot be readpublic void renderPageToGraphics(int pageIndex, Graphics2D graphics) throws IOException
Read renderPageToGraphics(int, Graphics2D, float, float, RenderDestination)
before using this.
pageIndex
- the zero-based index of the page to be convertedgraphics
- the Graphics2D on which to draw the pageIOException
- if the PDF cannot be readpublic void renderPageToGraphics(int pageIndex, Graphics2D graphics, float scale) throws IOException
Read renderPageToGraphics(int, Graphics2D, float, float, RenderDestination)
before using this.
pageIndex
- the zero-based index of the page to be convertedgraphics
- the Graphics2D on which to draw the pagescale
- the scaling factor, where 1 = 72 DPIIOException
- if the PDF cannot be readpublic void renderPageToGraphics(int pageIndex, Graphics2D graphics, float scaleX, float scaleY) throws IOException
Read renderPageToGraphics(int, Graphics2D, float, float, RenderDestination)
before using this.
pageIndex
- the zero-based index of the page to be convertedgraphics
- the Graphics2D on which to draw the pagescaleX
- the scale to draw the page at for the x-axis, where 1 = 72 DPIscaleY
- the scale to draw the page at for the y-axis, where 1 = 72 DPIIOException
- if the PDF cannot be readpublic void renderPageToGraphics(int pageIndex, Graphics2D graphics, float scaleX, float scaleY, RenderDestination destination) throws IOException
Known problems:
renderImage
methods.pageIndex
- the zero-based index of the page to be convertedgraphics
- the Graphics2D on which to draw the pagescaleX
- the scale to draw the page at for the x-axis, where 1 = 72 DPIscaleY
- the scale to draw the page at for the y-axis, where 1 = 72 DPIdestination
- controlling visibility of optional content groupsIOException
- if the PDF cannot be readpublic boolean isGroupEnabled(PDOptionalContentGroup group)
group
- the groupprotected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException
IOException
Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.