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

public final Class PDFPageable

extends Book
Class Inheritance
Imports
java.awt.RenderingHints, java.awt.print.Book, .PageFormat, .Paper, .Printable, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, org.apache.pdfbox.pdmodel.common.PDRectangle

Prints a PDF document using its original paper size.
Author
John Hewson

Field Summary

Modifier and TypeField and Description
private final boolean
private final PDDocument
private final float
private final int
private final Orientation
private RenderingHints
private final boolean
private boolean

Constructor Summary

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

Creates a new PDFPageable.

public
PDFPageable(PDDocument
the document to print
document
,
Orientation
page orientation policy
orientation
)

Creates a new PDFPageable with the given page orientation.

public
PDFPageable(PDDocument
the document to print
document
,
Orientation
page orientation policy
orientation
,
boolean
true if page borders are to be printed
showPageBorder
)

Creates a new PDFPageable with the given page orientation and with optional page borders shown.

public
PDFPageable(PDDocument
the document to print
document
,
Orientation
page orientation policy
orientation
,
boolean
true if page borders are to be printed
showPageBorder
,
float
if non-zero then the image will be rasterized at the given DPI
dpi
)

Creates a new PDFPageable with the given page orientation and with optional page borders shown.

public
PDFPageable(PDDocument
the document to print
document
,
Orientation
page orientation policy
orientation
,
boolean
true if page borders are to be printed
showPageBorder
,
float
if non-zero then the image will be rasterized at the given DPI
dpi
,
boolean
true if the content is to be centered on the page (otherwise top-left).
center
)

Creates a new PDFPageable with the given page orientation and with optional page borders shown.

Method Summary

Modifier and TypeMethod and Description
public int
getNumberOfPages()

Overrides java.awt.print.Book.getNumberOfPages.

Implements java.awt.print.Pageable.getNumberOfPages.

Returns the number of pages in this Book.

public PageFormat
getPageFormat(int
the zero based index of the page whose PageFormat is being requested
pageIndex
)

Overrides java.awt.print.Book.getPageFormat.

Implements java.awt.print.Pageable.getPageFormat.

Returns the PageFormat of the page specified by pageIndex.

public Printable
getPrintable(int
the zero based index of the page whose Printable is being requested
i
)

Overrides java.awt.print.Book.getPrintable.

Implements java.awt.print.Pageable.getPrintable.

Returns the Printable instance responsible for rendering the page specified by pageIndex.

public RenderingHints

Returns:

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

Get the rendering hints.

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.awt.print.Book:
appendappendsetPage

Field Detail

centerback to summary
private final boolean center
documentback to summary
private final PDDocument document
dpiback to summary
private final float dpi
numberOfPagesback to summary
private final int numberOfPages
orientationback to summary
private final Orientation orientation
renderingHintsback to summary
private RenderingHints renderingHints
showPageBorderback to summary
private final boolean showPageBorder
subsamplingAllowedback to summary
private boolean subsamplingAllowed

Constructor Detail

PDFPageableback to summary
public PDFPageable(PDDocument document)

Creates a new PDFPageable.

Parameters
document:PDDocument

the document to print

PDFPageableback to summary
public PDFPageable(PDDocument document, Orientation orientation)

Creates a new PDFPageable with the given page orientation.

Parameters
document:PDDocument

the document to print

orientation:Orientation

page orientation policy

PDFPageableback to summary
public PDFPageable(PDDocument document, Orientation orientation, boolean showPageBorder)

Creates a new PDFPageable with the given page orientation and with optional page borders shown.

Parameters
document:PDDocument

the document to print

orientation:Orientation

page orientation policy

showPageBorder:boolean

true if page borders are to be printed

PDFPageableback to summary
public PDFPageable(PDDocument document, Orientation orientation, boolean showPageBorder, float dpi)

Creates a new PDFPageable with the given page orientation and with optional page borders shown. The image will be rasterized at the given DPI before being sent to the printer if non-zero.

Parameters
document:PDDocument

the document to print

orientation:Orientation

page orientation policy

showPageBorder:boolean

true if page borders are to be printed

dpi:float

if non-zero then the image will be rasterized at the given DPI

PDFPageableback to summary
public PDFPageable(PDDocument document, Orientation orientation, boolean showPageBorder, float dpi, boolean center)

Creates a new PDFPageable with the given page orientation and with optional page borders shown. The image will be rasterized at the given DPI before being sent to the printer if non-zero, and optionally be centered.

Parameters
document:PDDocument

the document to print

orientation:Orientation

page orientation policy

showPageBorder:boolean

true if page borders are to be printed

dpi:float

if non-zero then the image will be rasterized at the given DPI

center:boolean

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

Method Detail

getNumberOfPagesback to summary
public int getNumberOfPages()

Overrides java.awt.print.Book.getNumberOfPages.

Implements java.awt.print.Pageable.getNumberOfPages.

Doc from java.awt.print.Book.getNumberOfPages.

Returns the number of pages in this Book.

Returns:int

the number of pages this Book contains.

Annotations
@Override
getPageFormatback to summary
public PageFormat getPageFormat(int pageIndex)

Overrides java.awt.print.Book.getPageFormat.

Implements java.awt.print.Pageable.getPageFormat.

Doc from java.awt.print.Book.getPageFormat.

Returns the PageFormat of the page specified by pageIndex. Returns the actual physical size of the pages in the PDF file. May not fit the local printer.

Parameters
pageIndex:int

the zero based index of the page whose PageFormat is being requested

Returns:PageFormat

the PageFormat describing the size and orientation of the page.

Annotations
@Override
getPrintableback to summary
public Printable getPrintable(int i)

Overrides java.awt.print.Book.getPrintable.

Implements java.awt.print.Pageable.getPrintable.

Doc from java.awt.print.Book.getPrintable.

Returns the Printable instance responsible for rendering the page specified by pageIndex.

Parameters
i:int

the zero based index of the page whose Printable is being requested

Returns:Printable

the Printable that renders the page.

Annotations
@Override
getRenderingHintsback to summary
public RenderingHints getRenderingHints()

Get the rendering hints.

Returns:RenderingHints

the rendering hints or null if none are set.

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.