Class AsposeWordsPrintDocument

  • java.lang.Object
    • com.aspose.words.AsposeWordsPrintDocument
  • All Implemented Interfaces:
    java.awt.print.Pageable, java.awt.print.Printable
    public class AsposeWordsPrintDocument 
    extends java.lang.Object

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

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.

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

    • Constructor Detail

      • AsposeWordsPrintDocument

        public AsposeWordsPrintDocument(Document document)
        Initializes a new instance of this class.
        document - The document to print.


        Shows the standard Java print dialog that allows selecting the printer and the specified page range to print the document with.
        Document doc = new Document(getMyDir() + "Rendering.doc");
        PrinterJob pj = PrinterJob.getPrinterJob();
        // Initialize the Print Dialog with the number of pages in the document.
        PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
        attributes.add(new PageRanges(1, doc.getPageCount()));
        // Returns true if the user accepts the print dialog.
        if (!pj.printDialog(attributes)) return;
        // Create the Aspose.Words' implementation of the Java Pageable interface.
        AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(doc);
        // Pass the document to the printer.
        // Print the document with the user specified print settings.