Word docx , Word docx . , docx , , .
, /word/numbering.xml.
, Test1.docx :

:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTNumbering;
import java.util.List;
import java.lang.reflect.Field;
public class CopyWordParagraphsDocToDoc {
public static void main(String[] args)throws Exception {
XWPFDocument docx1 = new XWPFDocument(new FileInputStream("Test1.docx"));
XWPFNumbering numberingDocx1 = docx1.getNumbering();
List<XWPFParagraph> paragraphListDocx1 = docx1.getParagraphs();
XWPFDocument docx2= new XWPFDocument();
if (numberingDocx1 != null) {
XWPFNumbering numberingDocx2 = docx2.createNumbering();
try {
Field f = numberingDocx1.getClass().getDeclaredField("ctNumbering");
f.setAccessible(true);
numberingDocx2.setNumbering((CTNumbering)f.get(numberingDocx1));
} catch (NoSuchFieldException nsfex) {
} catch (IllegalAccessException iaex) {
}
}
XWPFParagraph paragraphDocx2 = docx2.createParagraph();
XWPFRun run = paragraphDocx2.createRun();
run.setText("This is from Test1.docx:");
for (XWPFParagraph paragraphDocx1 : paragraphListDocx1) {
paragraphDocx2 = docx2.createParagraph();
docx2.setParagraph(paragraphDocx1, docx2.getPosOfParagraph(paragraphDocx2));
}
paragraphDocx2 = docx2.createParagraph();
run = paragraphDocx2.createRun();
run.setText("^-- this was from Test1.docx.");
FileOutputStream out = new FileOutputStream(new File("Test2.docx"));
docx2.write(out);
docx2.close();
System.out.println("Test2.docx written successfully");
}
}
Test2.docx :

:
, .
, /word/media/*.* .
, " 1", , /word/styles.xml.