get Printer Job - Java 2D Graphics

Java examples for 2D Graphics:Print

Description

get Printer Job

Demo Code


import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.HashPrintRequestAttributeSet;
import javax.print.attribute.PrintRequestAttributeSet;
import javax.print.attribute.standard.Copies;
import java.awt.*;
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;

public class Main{
    public static PrinterJob getPrinterJob(PrintService ps,
            Orientation orientation) throws PrinterException {
        final PrinterJob printJob = PrinterJob.getPrinterJob();
        printJob.setPrintService(ps);/*from w w w  . j a v  a  2  s .  co m*/
        final PageFormat pf = printJob.defaultPage();
        pf.setOrientation(orientation.value);
        return printJob;
    }
}

Related Tutorials