print option (For print page printer setting)

Hi Friends,i don't know what i use for page print.?it mean printer setting..and page setting A4 size printing..so what i wil use .? which API i use ?and any body have code of printer then reapl methank u
[253 byte] By [Jayesh_Javaa] at [2007-10-3 3:47:08]
# 1

Hi,

this is a piece of code I use to print out an image from a file:

//you should have these imports when using printing stuff, for the others figure out yourself

import javax.print.*;

import javax.print.attribute.*;

import javax.print.attribute.standard.*;

import javax.print.event.*;

try {

InputStream is = new BufferedInputStream(new

FileInputStream(sourceFile));

// Find the default service

DocFlavor flavor = DocFlavor.INPUT_STREAM.PNG;

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

aset.add(OrientationRequested.LANDSCAPE);

aset.add(Chromaticity.COLOR);

PrintService service = PrintServiceLookup.lookupDefaultPrintService();

// Create the print job

DocPrintJob job = service.createPrintJob();

Doc doc = new SimpleDoc(is, flavor, null);

// Monitor print job events; for the implementation of PrintJobWatcher,

// see e702 Determining When a Print Job Has Finished

PrintJobWatcher pjDone = new PrintJobWatcher(job)

// Print it

job.print(doc, aset);

// Wait for the print job to be done

pjDone.waitForDone();

// It is now safe to close the input stream

is.close();

}

catch (PrintException ex) {

JOptionPane.showMessageDialog(null, ex, "PrintException!", 0);

}

catch (IOException ex) {

JOptionPane.showMessageDialog(null, ex, "PrintException (IOException)!", 0);

}

catch (Exception ex) {

JOptionPane.showMessageDialog(null, ex, "PrintException (Exception)!", 0);

}

Rooster13a at 2007-7-14 21:44:02 > top of Java-index,Desktop,Core GUI APIs...