AsposeWordsPrintDocument

Inheritance: java.lang.Object

All Implemented Interfaces: java.awt.print.Pageable, java.awt.print.Printable

public class AsposeWordsPrintDocument implements Pageable, Printable

Provides a default implementation for printing of a Document within the Java printing framework.

To learn more, visit the Printing a Document Programmatically or Using Dialogs documentation article.

Remarks:

AsposeWordsPrintDocument overrides both java.awt.print.Printable and java.awt.print.Pageable.

A single Aspose.Words document can consist of multiple sections that specify pages with different sizes, orientation and paper trays. AsposeWordsPrintDocument should be used as java.awt.print.Pageable to properly print each of the different paper size, orientation, etc.

On the other hand, if the document consists of a single section only, the developer can use AsposeWordsPrintDocument as java.awt.print.Printable to improve printing performance.

Constructors

ConstructorDescription
AsposeWordsPrintDocument(Document document)Initializes a new instance of this class.

Methods

MethodDescription
getColorMode()Gets how non-colored pages are printed if the device supports color printing.
getColorPagesPrinted()Gets the number of pages printed in color (i.e.
getNumberOfPages()
getPageFormat(int pageIndex)
getPrintable(int pageIndex)
print(Graphics graphics, PageFormat pageFormat, int pageIndex)
setColorMode(int value)Sets how non-colored pages are printed if the device supports color printing.

AsposeWordsPrintDocument(Document document)

public AsposeWordsPrintDocument(Document document)

Initializes a new instance of this class.

Parameters:

ParameterTypeDescription
documentDocumentThe document to print.

getColorMode()

public int getColorMode()

Gets how non-colored pages are printed if the device supports color printing.

Remarks:

Doesn’t affect booklet printing.

Returns: int - How non-colored pages are printed if the device supports color printing. The returned value is one of ColorPrintMode constants.

getColorPagesPrinted()

public int getColorPagesPrinted()

Gets the number of pages printed in color (i.e. with PageSettings#getColor().getColor() / PageSettings#setColor(boolean).setColor(boolean) set to true).

Returns: int - The number of pages printed in color (i.e.

getNumberOfPages()

public int getNumberOfPages()

Returns: int

getPageFormat(int pageIndex)

public PageFormat getPageFormat(int pageIndex)

Parameters:

ParameterTypeDescription
pageIndexint

Returns: java.awt.print.PageFormat

getPrintable(int pageIndex)

public Printable getPrintable(int pageIndex)

Parameters:

ParameterTypeDescription
pageIndexint

Returns: java.awt.print.Printable

public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)

Parameters:

ParameterTypeDescription
graphicsjava.awt.Graphics
pageFormatjava.awt.print.PageFormat
pageIndexint

Returns: int

setColorMode(int value)

public void setColorMode(int value)

Sets how non-colored pages are printed if the device supports color printing.

Remarks:

Doesn’t affect booklet printing.

Parameters:

ParameterTypeDescription
valueintHow non-colored pages are printed if the device supports color printing. The value must be one of ColorPrintMode constants.