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

Free Support Forum - aspose.com

Move pointer in a document

Hi


Is it possible to jump straight to any other page in document and start working ( adding text ) from there?

thanks.

Hi,


Thanks for your inquiry. Yes, it is possible to move the cursor within a page and start working (adding text) from there. I have attached the input and output file for your ease. Please use the latest version of Aspose.Words for .NET and try following code. Hope this helps you.


Document doc = new Document(MyDir + "Document.docx");

DocumentBuilder builder = new DocumentBuilder(doc);

Node node = GetNodeByPageNumber(2, doc);

builder.MoveTo(node);

builder.Writeln("Adding New Text");

doc.Save(MyDir + "AWOutput.docx");

_____________________________________________________________________________

private static Node GetNodeByPageNumber(int page, Document document)

{

LayoutCollector layoutCollector = new LayoutCollector(document);

foreach (Node node in document.GetChildNodes(NodeType.Any, true))

{

if (layoutCollector.GetStartPageIndex(node) == page)

return node;

}

return null;
}


For more information, please visit Moving the Cursor. If you still face problems, please let us know we will try to help you as much we can. Thanks.