Print duplex in Java

How can I print duplex in java!?

Here's my code, but it didn't work - it only works in microsoft word (so the printer can do it)

PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
    pras.add(new Copies(2));
    pras.add(Sides.DUPLEX);

PrinterJob pj = PrinterJob.getPrinterJob();
    PageFormat pf = pj.defaultPage();
    Paper temp = pf.getPaper();

    temp.setImageableArea(1, 3, temp.getWidth(), temp.getHeight());
    pf.setPaper(temp);

    if (pj.printDialog(pras)) {
        try {
            pj.setPrintable(this, pf);
            pj.print(pras); //  Drucken
            return true;
        } catch (Exception PrintException) {
            .....
        }

I tried to give only the attributes to print, only to the dialog, etc. etc. etc. It print's the document 2 times, but not duplex! (also tried Sides.TWO_SIDED_LONG_EDGE..)

Upvotes: 1

Views: 4143

Answers (1)

The Problem was my printer,... it always turn the option for duplex to be disabled.

Upvotes: 1

Related Questions