Bonjour,
mon pblm est que l'image ne s'affiche pas dans mon fichier, voici mon code :
le fichier est créer mais l’image s’affiche pas Aidez-moi SVP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 private static void WordDocx(String filename,InputStream inn) throws IOException, InvalidFormatException { XWPFDocument document = new XWPFDocument(); XWPFParagraph tmpParagraph = document.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); tmpRun.setText("Image!"); tmpRun.setFontSize(18); int i=XWPFDocument.PICTURE_TYPE_PNG; document.addPicture(inn,i); document.write(new FileOutputStream(new File(filename + ".docx"))); // throw new UnsupportedOperationException("Not yet implemented"); } public static void main(String[]args) throws UnsupportedEncodingException, FileNotFoundException, IOException, InvalidFormatException { File fi=new File("C:/Users/developpeur/Documents/test.png"); FileImageInputStream fis = new FileImageInputStream(fi) ; int taille = (int)fi.length() * 8 ; byte[] bb = new byte[taille]; fis.read(bb); InputStream inn = new ByteArrayInputStream(bb) ; inn.read(); WordDocx("C:/Users/developpeur/Documents/testt",inn); }
merci d'avance
Partager