Printing help

How should i print from java ?
[37 byte] By [Kavarthapu.Madana] at [2007-10-2 0:55:51]
# 1

Here is a sample code.... modify to u r needs.

FileInputStream psStream;

try {

psStream = new FileInputStream("file.ps");

} catch (FileNotFoundException ffne) {

}

if (psStream == null) {

return;

}

DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;

Doc myDoc = new SimpleDoc(psStream, psInFormat, null);

PrintRequestAttributeSet aset =

new HashPrintRequestAttributeSet();

aset.add(new Copies(5));

aset.add(MediaSize.A4);

aset.add(Sides.DUPLEX);

PrintService[] services =

PrintServiceLookup.lookupPrintServices(psInFormat, aset);

if (services.length > 0) {

DocPrintJob job = services[0].createPrintJob();

try {

job.print(myDoc, aset);

} catch (PrintException pe) {}

}

Jogeswara_Raoa at 2007-7-15 18:15:47 > top of Java-index,Other Topics,Java Community Process (JCP) Program...
# 2

Hi,

I have two seperate images and I want to use javax print API to print the two images in duplex mode, means first image on front page, second image on back page, as far as I know, SimpleDoc can only construct one image at a time, so how to construct a document consisting two images as two pages?

Thanks a lot.

sharon_toa at 2007-7-15 18:15:47 > top of Java-index,Other Topics,Java Community Process (JCP) Program...