Printing a postscript file

Hi there,

I wonder if I'm missing something simple here...

I have this code, which quite happily prints postscript files to the designated printer, however it always prints duplex.

As you can see, I have added print request attributes to force single-sided and two copies, but both of these attributes are ignored.

PrintService defaultService = getDefaultPrintService();

if (defaultService !=null){

try{

DocPrintJob docPrintJob = defaultService.createPrintJob();

FileInputStream fileInputStream =new FileInputStream(printFile);

Doc doc =new SimpleDoc(fileInputStream, DocFlavor.INPUT_STREAM.POSTSCRIPT,null);

HashPrintRequestAttributeSet attribs =new HashPrintRequestAttributeSet();

attribs.add(Sides.ONE_SIDED);// <====

attribs.add(new Copies(2));// <====

docPrintJob.print(doc, attribs);

}catch (Exception e){

ExceptionHelper.logException(CLASS,"Print Failure", e);

thrownew DSEException(DSEException.critical,"","Input file name : " + outputFileName);

}finally{

// clean up - now delete the postscript file

printFile.delete();

}

}else{

thrownew DSEException(DSEException.critical,"","Default Printer Has Not Been Set Up: ");

}

I realise you cannot actually run this code, but it is a bit difficult to provide a working example, unless you have a postscript file hanging around (maybe that's simple?) but can anyone spot an obvious mistake in the code I've shown?

Thanks,

Tim

[2543 byte] By [TimRyanNZa] at [2007-10-3 8:10:44]
# 1
Bump
TimRyanNZa at 2007-7-15 3:15:09 > top of Java-index,Java Essentials,Java Programming...
# 2
Bump
TimRyanNZa at 2007-7-15 3:15:09 > top of Java-index,Java Essentials,Java Programming...
# 3
Does nobody do any printing like this? :-(
TimRyanNZa at 2007-7-15 3:15:09 > top of Java-index,Java Essentials,Java Programming...
# 4
I know zip about postscript, so this probably won't help (except for the bump),but andre uhres' printDemo class works well http://forum.java.sun.com/thread.jspa?threadID=614808
Michael_Dunna at 2007-7-15 3:15:09 > top of Java-index,Java Essentials,Java Programming...
# 5
Thanks Michael, I've had a quick look at that code and it isn't quite the same functionality - but I'll read it over again in more detail in case it helps. I'll give you a Duke Dollar for making the effort to reply.
TimRyanNZa at 2007-7-15 3:15:09 > top of Java-index,Java Essentials,Java Programming...