How to identify on which page my paragraph is there in word document using aspose.words?

how to identify on which page my paragraph is there…if first paragraph has 1 and half page of content and if i merge second paragraph then i will get second paragapth in mid of the page …in tht case how to idenfigy my second paragraph is on which page ?

Hi,


Thanks for your request. There is no direct method to get number of page where paragraph is located. However, you can try using code like the following to achieve this:

Document doc= new Document(@“c:\temp\in.docx”);
DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveToParagraph(1, 0);

// Insert a PAGE field and update it.
Field page = builder.InsertField(“PAGE”);
builder.Document.UpdatePageLayout();
page.Update();

int pageNumber = int.Parse(page.Result);

// Remove PAGE field.
page.Remove();

doc.Save(@“c:\temp\out.docx”);

I hope, this will help.

Best Regards,