Package com.tom_roush.pdfbox.rendering
Class PDFRenderer
- java.lang.Object
-
- com.tom_roush.pdfbox.rendering.PDFRenderer
-
public class PDFRenderer extends Object
Renders a PDF document to an AWT BufferedImage. This class may be overridden in order to perform custom rendering.
-
-
Field Summary
Fields Modifier and Type Field Description protected PDDocumentdocument
-
Constructor Summary
Constructors Constructor Description PDFRenderer(PDDocument document)Creates a new PDFRenderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected PageDrawercreatePageDrawer(PageDrawerParameters parameters)Returns a new PageDrawer instance, using the given parameters.android.graphics.BitmaprenderImage(int pageIndex)Returns the given page as an RGB image at 72 DPIandroid.graphics.BitmaprenderImage(int pageIndex, float scale, android.graphics.Bitmap.Config config)Returns the given page as an RGB image at the given scale.android.graphics.BitmaprenderImageWithDPI(int pageIndex, float dpi)Returns the given page as an RGB image at the given DPI.android.graphics.BitmaprenderImageWithDPI(int pageIndex, float dpi, android.graphics.Bitmap.Config imageType)Returns the given page as an RGB image at the given DPI.voidrenderPage(PDPage page, android.graphics.Paint paint, android.graphics.Canvas canvas, int width, int height, float scaleX, float scaleY)
-
-
-
Field Detail
-
document
protected final PDDocument document
-
-
Constructor Detail
-
PDFRenderer
public PDFRenderer(PDDocument document)
Creates a new PDFRenderer.- Parameters:
document- the document to render
-
-
Method Detail
-
renderImage
public android.graphics.Bitmap renderImage(int pageIndex) throws IOExceptionReturns the given page as an RGB image at 72 DPI- Parameters:
pageIndex- the zero-based index of the page to be converted.- Returns:
- the rendered page image
- Throws:
IOException- if the PDF cannot be read
-
renderImageWithDPI
public android.graphics.Bitmap renderImageWithDPI(int pageIndex, float dpi) throws IOExceptionReturns the given page as an RGB image at the given DPI.- Parameters:
pageIndex- the zero-based index of the page to be converteddpi- the DPI (dots per inch) to render at- Returns:
- the rendered page image
- Throws:
IOException- if the PDF cannot be read
-
renderImageWithDPI
public android.graphics.Bitmap renderImageWithDPI(int pageIndex, float dpi, android.graphics.Bitmap.Config imageType) throws IOExceptionReturns the given page as an RGB image at the given DPI.- Parameters:
pageIndex- the zero-based index of the page to be converteddpi- the DPI (dots per inch) to render atimageType- the type of image to return- Returns:
- the rendered page image
- Throws:
IOException- if the PDF cannot be read
-
renderImage
public android.graphics.Bitmap renderImage(int pageIndex, float scale, android.graphics.Bitmap.Config config) throws IOExceptionReturns the given page as an RGB image at the given scale.- Parameters:
pageIndex- the zero-based index of the page to be convertedscale- the scaling factor, where 1 = 72 DPIconfig- the bitmap config to create- Returns:
- the rendered page image
- Throws:
IOException- if the PDF cannot be read
-
renderPage
public void renderPage(PDPage page, android.graphics.Paint paint, android.graphics.Canvas canvas, int width, int height, float scaleX, float scaleY) throws IOException
- Throws:
IOException
-
createPageDrawer
protected PageDrawer createPageDrawer(PageDrawerParameters parameters) throws IOException
Returns a new PageDrawer instance, using the given parameters. May be overridden.- Throws:
IOException
-
-