Petite question d'impression...

cs_Youki Messages postés 19 Date d'inscription samedi 28 octobre 2000 Statut Membre Dernière intervention 25 mars 2004 - 24 mars 2004 à 17:16
cs_Youki Messages postés 19 Date d'inscription samedi 28 octobre 2000 Statut Membre Dernière intervention 25 mars 2004 - 25 mars 2004 à 12:29
Bonjour !

Bon, une question d'impression cette fois :

public class Navigateur extends JEditorPane implements Printable
{
int nb;
Navigateur(){
setEditable(false);
setContentType("text/html");
}
public void print(VueProjet vp){
PrinterJob printJob = PrinterJob.getPrinterJob();
printJob.setPrintable(this);
PageFormat pf = printJob.pageDialog(printJob.defaultPage());
Book bk = new Book();
bk.append((Printable)this, pf);
printJob.setPageable(bk);
nb = bk.getNumberOfPages();
int n = JOptionPane.showConfirmDialog(vp,"Valider l'impression ?","Impression de documents...",JOptionPane.YES_NO_OPTION);
if(n==JOptionPane.YES_OPTION){
try { printJob.print(); } catch (Exception e) { }
}
}
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException {
int nbPages = (int)Math.ceil(((double)this.getHeight()) /pf.getImageableHeight());
System.out.println(pi+" "+nbPages);
if (pi >= nbPages) {
return Printable.NO_SUCH_PAGE;
}

Graphics2D g2 = (Graphics2D)g;
double l=this.getWidth();
System.out.println(this.getHeight());
double l2=pf.getImageableWidth();
g2.setClip(0, (int)(pf.getImageableHeight() * pi) , (int)l , (int)pf.getImageableHeight());
g2.translate(pf.getImageableX(),pf.getImageableY()-(pf.getImageableHeight()*pi));
if(l>l2){
l=l2/l;
}else{
l=l/l2;
}
g2.scale(l,l);
//Font f = new Font("Monospaced", font.PLAIN, 12);
//g2.setFont(f);
paint(g2);

return Printable.PAGE_EXISTS;
}

Voila la question :
J'ai, dans mon JEditorPane, un document qui fait 8 pages à l'impression... mon nbPages est bien égal à 8, alors pourquoi il m'imprime qu'une seule page ???

duanra

1 réponse

cs_Youki Messages postés 19 Date d'inscription samedi 28 octobre 2000 Statut Membre Dernière intervention 25 mars 2004
25 mars 2004 à 12:29
heu... S'il vous plaît ?

duanra
0
Rejoignez-nous