我知道这个帖子很旧,但是我仍然发布答案,所有寻找这个答案的人都可以使用它.
为了将图片插入word文档中,您必须编写两个程序.第一个是: –
package org.word.POI;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xwpf.usermodel.Document;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
/*
Romesh Soni
soni.romesh@gmail.com
*/
public class TestCustom
{
public static void main(String []a) throws FileNotFoundException, IOException, InvalidFormatException
{
CustomXWPFDocument document = new CustomXWPFDocument(new FileInputStream(new File("C:\\Users\\amitabh\\Documents\\Apache POI\\Word File\\new.doc")));
FileOutputStream