• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing in java: How to set paper size

 
Rahul Rao
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am printing a documenmt. the need of the document is such that the data is spread on a sheet a little longer than an A4 size paper. I wish to change the paper size by increasing the lenght upto which the printing happens on a A4. How do I set the paper size of this for the purpose of printing.
 
Gopi Kishore
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check this out, some changes to be done when u add

javax.print.attribute.standard.MediaSize
javax.print.attribute.standard.MediaSizeName

DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
Doc myDoc = new SimpleDoc(pstream, psInFormat, null);
PrintRequestAttributeSet aset =
new HashPrintRequestAttributeSet();
aset.add(new Copies(5));
aset.add(MediaSizeName.ISO_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) {}
}
[ May 26, 2005: Message edited by: Gopi Kishore ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic