Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No. of copies for printing..Urgent..please

 
eric mt
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am using jdk1.2.2 for printing,which utilises java.awt.print package,PageFormat and PrinterJob classes with interface Printable.When i run my program in Windows it will take the
page-set-up of windows itself.But i am not able to get multiple copies when i change the values in the option provided with the PrintDialog that comes for the same.A part of my code is mentioned below...
here i am doing
>>>>>
PrinterJob pj = PrinterJob.getPrinterJob();
PageFormat pf = pj.pageDialog(pj.defaultPage());
and after
>>>>>>
class PrintableClass implements Printable
{
BufferedImage bi;
public PrintableClass(BufferedImage bim,PageFormat pf) {
bi = bim;
}
public int print(Graphics g,PageFormat pf,int pageIndex) {
if(pageIndex != 0) return NO_SUCH_PAGE;
Graphics2D g2 = (Graphics2D)g;
g2.setPaint(Color.black);
g2.drawImage(bi,(int)pf.getImageableX(),(int)pf.getImageableY(),null);
return PAGE_EXISTS;
}
please somebody can help.....
Thanks in advance...Eric
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Printing API questions should really go to the "Other Java APIs" forum, so I've moved this message.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic