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

Free Support Forum - aspose.com

How to move to paragraph start

Hi aspose team,

I want to move to paragraph start and insert a book mark over there.

i am trying dbuilder.moveToParagraph

but it gives java.lang.NullPointerException
at com.aspose.words.DocumentBuilder.getCurrentStory(DocumentBuilder.java:1840)
at com.aspose.words.DocumentBuilder.moveToParagraph(DocumentBuilder.java:343)

or is there any other way?

Please help me out..



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Yes, you are right, you should use moveToParagraph method in this case. Could you please attach your document and provide me a simple code, which will allow me to reproduce the problem on my side? I will check the issue and provide you more information.

Best regards.


Attaching a document

NodeCollection sectionParas = doc.getChildNodes(NodeType.PARAGRAPH, true);

Map map = new HashMap();
int paraSequence=-1;
for(Paragraph para:sectionParas){
map.put(para, paraSequence);

for(Paragraph sectionPara:sectionParas){



Please reply

Thanks in advance


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Your code works fine on my side. Also, please try using the following code:

Document doc = new Document("C:\\Temp\\finalWordDoc.doc");

DocumentBuilder dbuilder = new DocumentBuilder(doc);

for(Section section : doc.getSections())


// Move DocumentBuilder cursor into the current section.


NodeCollection<Paragraph> sectionParas = section.getChildNodes(NodeType.PARAGRAPH, true);

for(Paragraph par : sectionParas)


// Move cursor to the beginning of the current paragraph.

dbuilder.moveToParagraph(sectionParas.indexOf(par), 0);

// Insert some text to make sure our code works correct.




// Save output document.


Best regards.