We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Order of Runs


I have a problem of collecting Runs (located in text boxes) in the right order from the document I have attached. Instead of getting “One”, “Two”, “Three”, “Four”, “Five”, “Six”, I get them in somewhat reverse order “Three”, “Two”, “One” and “Six”, “Five”, “Four”. Each word marks the order in which text boxes were inserted in the document. Do you maybe know if text boxes are influencing the order in which Runs will be visited? If they are, how?

public void getAsposeRuns() throws Exception {
Document doc = new Document(“Test1.docx”);
List runs = getRuns(doc);
for (Run run : runs) {

private List getRuns(Document document) throws Exception {
final List runs = new ArrayList();
document.accept(new DocumentVisitor() {
public int visitRun(Run run) throws Exception {
return super.visitRun(run);
return runs;

Hi Zeljko,

Thanks for your inquiry.
I get them in somewhat reverse order “Three”, “Two”, “One” and “Six”, “Five”, “Four”.
This is the correct order. I have attached “Document.xml” here for your reference. Please open this file with Notepad and search the strings “Three”, then “Two” and then “One”. You’ll notice that three comes before two and two before one. So, Aspose.Words for Java reads these Run nodes in correct order. If we can help you with anything else, please feel free to ask.

Best regards,