我有这段代码:
public class ImageAttachmentInDocument {
/**
* @param args
* @throws IOException
* @throws InvalidFormatException
*/
public static void main(String[] args) throws IOException, InvalidFormatException {
XWPFDocument doc = new XWPFDocument();
FileInputStream is = new FileInputStream("encabezado.jpg");
doc.addPictureData(IOUtils.toByteArray(is), doc.PICTURE_TYPE_JPEG);
XWPFParagraph title = doc.createParagraph();
XWPFRun run = title.createRun();
run.setText("Fig.1 A Natural Scene");
run.setBold(true);
title.setAlignment(ParagraphAlignment.CENTER);
FileOutputStream fos = new FileOutputStream("test4.docx");
doc.write(fos);
fos.flush();
fos.close();
}
}
我正在使用Eclipse IDE中的Apache POI 3.11和xmlbeans-2.3.0。
在生成文档时,图片没有显示出来。
我做错了什么?