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

Free Support Forum - aspose.com

Document Visitor

Hi,


Highlighted paragraph in the screenshot is skipped by your Document Visitor.
If you run the code below you will get:

PARAGRAPH START
PARAGRAPH END
TABLE END
PARAGRAPH START
FIELD START
PARAGRAPH END

I expected it to be:

PARAGRAPH START
PARAGRAPH END
TABLE END
PARAGRAPH START
PARAGRAPH END
PARAGRAPH START
FIELD START
PARAGRAPH END

Can you please check this out?

Thanks,
Zeljko


Code:

public void paragraphTest() throws Exception {
Document document = new Document(“Test.rtf”);
document.accept(new DocumentVisitor() {
@Override
public int visitParagraphEnd(Paragraph paragraph) throws Exception {
System.out.println(“PARAGRAPH END”);
return super.visitParagraphEnd(paragraph);
}
public int visitParagraphStart(Paragraph paragraph) throws Exception {
System.out.println(“PARAGRAPH START”);
return super.visitParagraphStart(paragraph);
}
public int visitTableEnd(Table table) throws Exception {
System.out.println(“TABLE END”);
return super.visitTableEnd(table);
}
public int visitFieldStart(FieldStart field) throws Exception {
System.out.println(“FIELD START”);
return super.visitFieldStart(field);
}
});
}

Additional information:
If you modify the document (for example: delete last three pages) the above mentioned paragraph will be visited.

Hi Zeljko,


Thanks for your inquiry. Please call Document.ensureMinimum method after loading the document to fix this issue. Hope this helps you.

Document document = new Document(MyDir + “Test.rtf”);<o:p></o:p>

document.ensureMinimum();

document.accept(new DocumentVisitor() {...

Hi,


Thank you for the suggestion.
This method’s description says: If the document contains no sections, creates one section with one paragraph.
As far as I can see this document has two sections so I am not sure why I need to execute this method? Is there something wrong with the document that I am missing out or this method should be executed for every loaded document?

Thanks,
Zeljko




Hi Zeljko,

Thanks for your inquiry. We have logged this problem in our issue tracking system as WORDSNET-13510. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.