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

Free Support Forum - aspose.com

Retrieving section number of current location in document

Is there a way to find out the current section index number?
For example, I movetobookmark X and I want to know what section I am in so that I can use the doc.sections(x).pagesetup command. I see builder.currentsection, but I couldn't find anything that returns the index number of the section.

Thanks

Donna

Hi

Thanks for your inquiry. I think that you can try using the following code snippet.

//Open dcument

Document doc = new Document(@"in.doc");

//Create builder

DocumentBuilder builder = new DocumentBuilder(doc);

//Move to bookmark

builder.MoveToBookmark("myBookmark");

//Get index of the current section

int sectionIndex = doc.Sections.IndexOf(builder.CurrentSection);

Hope this helps.

Best regards.

Perfect!!

I knew it had to be there somewhere.

Thanks again

Donna