If anyone could help, I am not sure if this is even possible, but I am searching the document for some specific text and need to return the page number that this text is on. Is this possible? Or are things like page numbers calculated after the actual document is created.
Hi Eddie,
Thanks for your query. Please use the following code snippet for your requirement. Hope this helps you. Please let us know if you have any more queries.
<span style=“font-family: “Courier New”; color: rgb(43, 145, 175);” lang=“EN-GB”>Document<span style=“font-family: “Courier New”;” lang=“EN-GB”> doc = new
Document(MYDir + “in.docx”);<o:p></o:p>
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();
Field page = builder.insertField("PAGE", "");
page.update();
System.out.println(page.getResult());
Thank you. This is exactly what I am looking for.
Hi Eddie,
// Remove PAGE field.<o:p></o:p>
page.Remove();
Thanks for further information on this. So just to clarify, it sounds like the reason this is sometimes returning an incorrect page number is due to the Aspose.Words page layout algorithm calculating an approximation? It just seems unusual, because when it is wrong, it usually returns specifically a page number of one. Anything other than one and the algorithm is always right from what I have seen.
Hi Eddie,
Thanks for your inquiry. I would like to share with you that MS Word document is flow document. It means that it does not contain any information about its layout into lines and pages. Pages are created by MS Word on the fly and Aspose.Words
uses our own Rendering Engine to layout documents into pages.
It would be great if you please share your document for which you are getting wrong page number by using DocumentBuilder.insertField method for investigation purposes.
Hi Eddie,
The issues you have found earlier (filed as WORDSNET-2978) have been fixed in this .NET update and this Java update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(64)