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

Free Support Forum - aspose.com

Word Field Visitor

Hi,

I have problem with field in attached document, field end is in second paragraph but other part of field are in first paragraph. Can you tell me is problem in visitor or field? Here is my test:

public class FieldAspose {

@Test
public void test() throws Exception {
Document doc = new Document(“Onefield.doc”);
FieldIterator iterator = new FieldIterator();
doc.accept(iterator);
}

}


import com.aspose.words.DocumentVisitor;
import com.aspose.words.FieldEnd;
import com.aspose.words.FieldSeparator;
import com.aspose.words.FieldStart;
import com.aspose.words.Paragraph;

public class FieldIterator extends DocumentVisitor {

public int visitParagraphStart(Paragraph paragraph) throws Exception {
System.out.println(“VisitParagraphStart”);
return super.visitParagraphStart(paragraph);
}

public int visitParagraphEnd(Paragraph paragraph) throws Exception {
System.out.println(“VisitParagraphEnd”);
return super.visitParagraphEnd(paragraph);
}

public int visitFieldStart(FieldStart fieldStart) throws Exception {
System.out.println(“Field Start”);
return super.visitFieldStart(fieldStart);
}

public int visitFieldEnd(FieldEnd fieldEnd) throws Exception {
System.out.println(“Field End”);
return super.visitFieldEnd(fieldEnd);
}

@Override
public int visitFieldSeparator(FieldSeparator fieldSeparator)
throws Exception {
System.out.println(“Field Separator”);
return super.visitFieldSeparator(fieldSeparator);
}

}


I got this field in one bigger document and all works fine for other fields but this makes me problem.

Thanks

Hi Djordje,


Thanks for your inquiry. After an initial test with Aspose.Words for Java 14.7.0, I was unable to reproduce this issue on my side. I would suggest you please upgrade to the latest version of Aspose.Words. You can download it from the following link. I hope, this helps.
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/default.aspx

When running your code with Aspose.Words 14.7.0, the Java console displays the following output:

VisitParagraphStart
Field Start
Field Separator
VisitParagraphEnd
VisitParagraphStart
Field End
VisitParagraphEnd

Best regards,

Hi,


You ARE ABLE to reproduce, You see that FieldStart and FieldSeparator in one Paragraph and FieldEnd in other. How can we have ParagraphEnd and ParagraphStart between FieldSeparator and FieldEnd? Is this regular field, especialy we can not see that ParagraphStart end ParagraphEnd in .doc file?

Hi Djordje,


Thanks for your inquiry. You can reveal the actual structure of this document by opening it with DocumentExplorer sample project:
http://www.aspose.com/docs/display/wordsjava/Document+Tree+Navigation

Best regards,