I am copying a run in the current paragraph into a prior paragraph (priorP). XmlObject newRunXml = run.getCTR().copy(); XWPFRun newRun = new XWPFRun((CTR) newRunXml, (IRunBody) priorP); priorP.addRun(newRun); This last method call only adds the run to the run collection, not the iRun collection and is never written on write to file (possible as a result). A workaround is to write my own addRun method, based on the protected addRun method in XWPFParagraph: private static void addRun(XWPFParagraph p, CTR run) { CTP ctp = p.getCTP(); int pos = ctp.sizeOfRArray(); ctp.addNewR(); ctp.setRArray(pos, run); }
Just use public methods, if you write your own addRun method, you should always update runs and iruns. The issue is fixed via r1889551.