Hi,
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?
Code:
public void getAsposeRuns() throws Exception {
Document doc = new Document(“Test1.docx”);
List runs = getRuns(doc);
for (Run run : runs) {
System.out.println(run.getText());
}
}
private List getRuns(Document document) throws Exception {
final List runs = new ArrayList();
document.accept(new DocumentVisitor() {
@Override
public int visitRun(Run run) throws Exception {
runs.add(run);
return super.visitRun(run);
return super.visitRun(run);
}
});
return runs;
}