How to create a new node of any type before/after a certain node in DOC.
Please help.
I am using Aspose.words API for java version 2.4.1.0
Thanks & regards
Thangaraj
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your inquiry. I think that you can use insertAfter and insertBefore methods. Please see the following link for more information.
Also see the following example.
// Create new document
Document doc = new Document();
// Get first paragraph from document
Paragraph par = doc.getFirstSection().getBody().getFirstParagraph();
// Create new run
Run run1 = new Run(doc, "this is run");
// Add run to paragraph
par.appendChild(run1);
// Create another run
Run run2 = new Run(doc, "this is another run");
// Insert run2 before run1
run1.getParentNode().insertBefore(run2, run1);
Hope this helps.
Best regards.