Top Description Fields Constructors Methods
org.apache.pdfbox.printing

public final Class PDFPrintable

extends Object
implements Printable
Class Inheritance
All Implemented Interfaces
java.awt.print.Printable
Imports
java.awt.BasicStroke, .Color, .Graphics, .Graphics2D, .RenderingHints, java.awt.geom.AffineTransform, java.awt.image.BufferedImage, java.awt.print.PageFormat, .Printable, .PrinterException, .PrinterIOException, java.io.IOException, org.apache.commons.logging.Log, .LogFactory, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, .PDPageTree, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.rendering.PDFRenderer, .RenderDestination

Prints pages from a PDF document using any page size or scaling mode.
Author
John Hewson

Field Summary

Modifier and TypeField and Description
private final boolean
private final float
private static final Log
private final PDPageTree
public static final float
public static final float
private final PDFRenderer
private RenderingHints
private final Scaling
private final boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
PDFPrintable(PDDocument
the document to print
document
)

Creates a new PDFPrintable.

public
PDFPrintable(PDDocument
the document to print
document
,
Scaling
page scaling policy
scaling
)

Creates a new PDFPrintable with the given page scaling.

public
PDFPrintable(PDDocument
the document to print
document
,
Scaling
page scaling policy
scaling
,
boolean
true if page borders are to be printed
showPageBorder
)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown.

public
PDFPrintable(PDDocument
the document to print
document
,
Scaling
page scaling policy
scaling
,
boolean
true if page borders are to be printed
showPageBorder
,
float
if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.
dpi
)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown.

public
PDFPrintable(PDDocument
the document to print
document
,
Scaling
page scaling policy
scaling
,
boolean
true if page borders are to be printed
showPageBorder
,
float
if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.
dpi
,
boolean
true if the content is to be centered on the page (otherwise top-left).
center
)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown.

public
PDFPrintable(PDDocument
the document to print
document
,
Scaling
page scaling policy
scaling
,
boolean
true if page borders are to be printed
showPageBorder
,
float
if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.
dpi
,
boolean
true if the content is to be centered on the page (otherwise top-left).
center
,
PDFRenderer
the document renderer. Useful if PDFRenderer has been subclassed.
renderer
)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown.

Method Summary

Modifier and TypeMethod and Description
public RenderingHints

Returns:

the rendering hints or null if none are set.
getRenderingHints
()

Get the rendering hints.

pack-priv static PDRectangle

Returns:

The CropBox at this level in the hierarchy.
getRotatedCropBox
(PDPage page)

This will find the CropBox with rotation applied, for this page by looking up the hierarchy until it finds them.

pack-priv static PDRectangle

Returns:

The MediaBox at this level in the hierarchy.
getRotatedMediaBox
(PDPage page)

This will find the MediaBox with rotation applied, for this page by looking up the hierarchy until it finds them.

public boolean

Returns:

true if subsampling of images is allowed, false otherwise.
isSubsamplingAllowed
()

Value indicating if the renderer is allowed to subsample images before drawing, according to image dimensions and requested scale.

public void
setRenderingHints(RenderingHints
rendering hints to be used to influence rendering quality and speed
renderingHints
)

Set the rendering hints.

public void
setSubsamplingAllowed(boolean
The new value indicating if subsampling is allowed.
subsamplingAllowed
)

Sets a value instructing the renderer whether it is allowed to subsample images before drawing.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

centerback to summary
private final boolean center
dpiback to summary
private final float dpi
LOGback to summary
private static final Log LOG
pageTreeback to summary
private final PDPageTree pageTree
RASTERIZE_DPI_AUTOback to summary
public static final float RASTERIZE_DPI_AUTO
RASTERIZE_OFFback to summary
public static final float RASTERIZE_OFF
rendererback to summary
private final PDFRenderer renderer
renderingHintsback to summary
private RenderingHints renderingHints
scalingback to summary
private final Scaling scaling
showPageBorderback to summary
private final boolean showPageBorder
subsamplingAllowedback to summary
private boolean subsamplingAllowed

Constructor Detail

PDFPrintableback to summary
public PDFPrintable(PDDocument document)

Creates a new PDFPrintable.

Parameters
document:PDDocument

the document to print

PDFPrintableback to summary
public PDFPrintable(PDDocument document, Scaling scaling)

Creates a new PDFPrintable with the given page scaling.

Parameters
document:PDDocument

the document to print

scaling:Scaling

page scaling policy

PDFPrintableback to summary
public PDFPrintable(PDDocument document, Scaling scaling, boolean showPageBorder)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown.

Parameters
document:PDDocument

the document to print

scaling:Scaling

page scaling policy

showPageBorder:boolean

true if page borders are to be printed

PDFPrintableback to summary
public PDFPrintable(PDDocument document, Scaling scaling, boolean showPageBorder, float dpi)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown. The image will be rasterized at the given DPI before being sent to the printer.

Parameters
document:PDDocument

the document to print

scaling:Scaling

page scaling policy

showPageBorder:boolean

true if page borders are to be printed

dpi:float

if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.

PDFPrintableback to summary
public PDFPrintable(PDDocument document, Scaling scaling, boolean showPageBorder, float dpi, boolean center)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown. The image will be rasterized at the given DPI before being sent to the printer.

Parameters
document:PDDocument

the document to print

scaling:Scaling

page scaling policy

showPageBorder:boolean

true if page borders are to be printed

dpi:float

if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.

center:boolean

true if the content is to be centered on the page (otherwise top-left).

PDFPrintableback to summary
public PDFPrintable(PDDocument document, Scaling scaling, boolean showPageBorder, float dpi, boolean center, PDFRenderer renderer)

Creates a new PDFPrintable with the given page scaling and with optional page borders shown. The image will be rasterized at the given DPI before being sent to the printer.

Parameters
document:PDDocument

the document to print

scaling:Scaling

page scaling policy

showPageBorder:boolean

true if page borders are to be printed

dpi:float

if positive non-zero then the image will be rasterized at the given DPI. If set to the special value RASTERIZE_DPI_AUTO, the dpi of the printer will be used.

center:boolean

true if the content is to be centered on the page (otherwise top-left).

renderer:PDFRenderer

the document renderer. Useful if PDFRenderer has been subclassed.

Method Detail

getRenderingHintsback to summary
public RenderingHints getRenderingHints()

Get the rendering hints.

Returns:RenderingHints

the rendering hints or null if none are set.

getRotatedCropBoxback to summary
pack-priv static PDRectangle getRotatedCropBox(PDPage page)

This will find the CropBox with rotation applied, for this page by looking up the hierarchy until it finds them.

Returns:PDRectangle

The CropBox at this level in the hierarchy.

getRotatedMediaBoxback to summary
pack-priv static PDRectangle getRotatedMediaBox(PDPage page)

This will find the MediaBox with rotation applied, for this page by looking up the hierarchy until it finds them.

Returns:PDRectangle

The MediaBox at this level in the hierarchy.

isSubsamplingAllowedback to summary
public boolean isSubsamplingAllowed()

Value indicating if the renderer is allowed to subsample images before drawing, according to image dimensions and requested scale. Subsampling may be faster and less memory-intensive in some cases, but it may also lead to loss of quality, especially in images with high spatial frequency.

Returns:boolean

true if subsampling of images is allowed, false otherwise.

setRenderingHintsback to summary
public void setRenderingHints(RenderingHints renderingHints)

Set the rendering hints. Use this to influence rendering quality and speed. If you don't set them yourself or pass null, PDFBox will decide at runtime depending on the destination.

Parameters
renderingHints:RenderingHints

rendering hints to be used to influence rendering quality and speed

setSubsamplingAllowedback to summary
public void setSubsamplingAllowed(boolean subsamplingAllowed)

Sets a value instructing the renderer whether it is allowed to subsample images before drawing. The subsampling frequency is determined according to image size and requested scale. Subsampling may be faster and less memory-intensive in some cases, but it may also lead to loss of quality, especially in images with high spatial frequency.

Parameters
subsamplingAllowed:boolean

The new value indicating if subsampling is allowed.