• Post Reply Bookmark Topic Watch Topic
  • New Topic

Printing more than one page  RSS feed

 
Raja Kannappan
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to print the contents of JHelpContentViewer, which is a sub-class of JComponent. I am able to print only the first page (i.e only the portion which is visible in the screen). The contents and length of JHelpContentViewer is dynamic. JHelpContentViewer will have scroll bar if the contents are more than the visible area.
This is the code:
public int
print(Graphics g, PageFormat pf, int pi) throws PrinterException
{
Graphics g2d = (Graphics2D) g.create();
int x = (int)pf.getImageableX();
int y = (int)pf.getImageableY();
int hPage = (int)pf.getImageableHeight();
int wPage = (int)pf.getImageableWidth();
if (pi == 0)
{
g2d.translate(x,y);
g2d.setClip(0,0,wPage,hPage);
}
else
{
g2d.translate(x,-(pi*hPage));
g2d.setClip(0,0,wPage,hPage);
}
if (pi >= 3)
return NO_SUCH_PAGE;
else
{
contentViewer.paint(g2d);
return Printable.PAGE_EXISTS;
}
}
Can someone tell me how to print all the pages?
Any help will be greatly appreciated.
Thanks,
- Raja.
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to Swing.
 
raj madhuram
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This might help you.
http://www.coderanch.com/t/335516/GUI/java/print-multiple-pages-printer
regards,
Raj
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!