number of pages to print in JEditorPane

Greetings,

I'm trying to print the (html) contents of a JEditorPane with the following.

publicint print(Graphics g, PageFormat pf,int pi)throws PrinterException{

if (pi >= 2){

return Printable.NO_SUCH_PAGE;

}

// shift the graphics to the selected page

g.translate( (int)pf.getImageableX(),

(int)(pf.getImageableY() - pf.getImageableHeight()*pi) );

myJEditorPane.paint(g);

return Printable.PAGE_EXISTS;

}

This works fine for the first two pages. The problem is that I don't know how to determine the actual number of pages. How can I tell how many pages there are to print?

Thanks,

Keith

[1120 byte] By [keith_100a] at [2007-10-2 21:51:26]
# 1
you have the page height int ph=pf.getImageableHeight()and int totalHeight=myJEditorPane.getHeight();int pageCount=totalHeight%ph+1;regards,Stas
StanislavLa at 2007-7-14 1:07:18 > top of Java-index,Desktop,Core GUI APIs...