Salut je cherche comment faire pour imprimer mon vecteur de n images sur n page en lancant une seule fois une impression.
Mais le probleme c que je n'est jamais imprimer en java et donc je ne sais pas comment on fait.
;)
Version imprimable
Salut je cherche comment faire pour imprimer mon vecteur de n images sur n page en lancant une seule fois une impression.
Mais le probleme c que je n'est jamais imprimer en java et donc je ne sais pas comment on fait.
;)
On commence par faire un minimum d'efforts de recherche: "Imprimer en java" sur Google, par exemple... et ensuite, on vient poser sa question pour avoir de l'aide si on rencontre un problème technique précis (et non pour qu'on fasse tout le travail à ta place).
Regarder du cote des classes PrinterJob et Printable. Il faut cependant quelques bases minimales en Java2D/dessin en Java.
salut,
voila enfaite j'ai deja un code de fait:
Mais le truc, c'est que sa m'imprime qu'une seule page a la fois.Code:
1
2
3
4
5
6
7
8
9
10 Properties props = new Properties(); props.put("awt.print.paperSize", "a4"); props.put("awt.print.destination", "printer"); PrintJob pJob = this.getToolkit().getPrintJob(this,"Printing_Test", props); Graphics pg = pJob.getGraphics(); panelImprime.printAll(pg); pg.dispose(); pJob.end();
panelImprime correspond au panel ou est située mon image.
Enfaite je voudrai imprimer plusieurs panel en même temps mais je sais pas comment faire !!
help me !
re,
j'ai trouver comment faire pour imprimer plusieurs page a la fois sauf que j'ai un probleme, lorsque que je lance l'impression j'ai une page blanche qui sort:
Voici mon code :
Puis mon appel:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13 public class PrinterImage implements Printable{ private Image img; public PrinterImage(Image img){ this.img=img; } public int print(Graphics arg0, PageFormat arg1, int arg2) throws PrinterException { if (arg2>0) return Printable.NO_SUCH_PAGE; arg0.drawImage(img,500,500,null); return Printable.PAGE_EXISTS; }
Si quelqu'un pouvais m'aider ce serai cool :aie:Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 Tiff t = new Tiff(); try { InputStream image = MaJtable.getListeFax().get(MaJtable.getIndexLigneSelectioner()).getImage(); t.readInputStream(image); } catch (IOException e1) { e1.printStackTrace(); } PrinterJob pJob=PrinterJob.getPrinterJob(); PageFormat pf = pJob.defaultPage(); pf.setOrientation(0); Book myBook = new Book(); for(i=0;i<imageCount;i++){ System.out.println(i); myBook.append(new Test(t.getImage(i)),pf); } pJob.setPageable(myBook); if(pJob.printDialog()) try { pJob.print(); } catch (PrinterException exception) { JOptionPane.showMessageDialog(this, exception); } }
salut j'ai changer ma class PrinterImage mais sa me fait toujours le même problème :
Une autre soluce ???Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 public class Test extends JPanel implements Printable{ private static final long serialVersionUID = 1L; private Image img; public Test(Image img){ this.img=img; } public int print(Graphics arg0, PageFormat arg1, int arg2) throws PrinterException { if (arg2>0) return Printable.NO_SUCH_PAGE; arg0.drawImage(img,500,500,this); return Printable.PAGE_EXISTS; } }
c'est bon j'ai reussi !!
Merci pour ton aide ;)