Hi,
I can’t find it in a documentation, but it seems like that if you take an existing node from the document and then inserts it at some other place in that same document, that node is actually moved from it’s original position to the new one. Here’s some sample code:
String wordFilePath = "Content Controls Test File 2007.docx";
Document wordDoc = new Document(wordFilePath);
StructuredDocumentTag childSdt = (StructuredDocumentTag) wordDoc.getChild(NodeType.STRUCTURED_DOCUMENT_TAG, 1,
true);
Paragraph parentParagraph = (Paragraph) wordDoc.getChild(NodeType.PARAGRAPH, 6, true);
Run run = (Run) parentParagraph.getChild(NodeType.RUN, 0, true);
DocumentBuilder db = new DocumentBuilder(wordDoc);
db.moveTo(run);
db.insertNode(childSdt);
wordDoc.save("Content Controls Test File 2007_MOVE.docx");
Can you please check this with devs so I can get a confirmation from them if this is expected and desired behavior or not?
Regards,
Zeljko