• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Printing jframe in A5 paper

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to print jframe contain in A5 paper.I've print it.But i don't know how to set A5 paper.
this is my printing code.

PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(this);
boolean ok = job.printDialog();
if (ok) {
try {
job.print();
} catch (PrinterException ex) {

}
}

Can any one help me.
Thank.
 
Shashika Thiran
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've find out answer for my problem.I've post it everyone to know.
It's simply like this

try {
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
PrintRequestAttributeSet printRequestAttrSet = new HashPrintRequestAttributeSet();
printRequestAttrSet.add(MediaSizeName.ISO_A5);
printRequestAttrSet.add(new MediaPrintableArea((float)0.0,(float)0.0,350,500, MediaPrintableArea.MM));
printJob.printDialog(printRequestAttrSet);
printJob.print(printRequestAttrSet);

}catch (PrinterException ex) {
ex.printStackTrace();
}
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic