Location of a shape

Hi,

Is there a function in Aspose.Words .NET that can expose the exact position of a shape on a page?
I need to know the position of the shape without knowing the position of the anchor, margins, alignment etc, just the exact position.

And is there a function to get back the pagenumber this shape is on?

Thanks in advance,

Kind regards,

Kris

Hi Kris,

Thanks for your inquiry. Aspose.Words uses our own Rendering Engine to layout documents into pages. The Aspose.Words.Layout namespace provides
classes that allow to access information such as on what page and where
on a page particular document elements are positioned, when the document
is formatted into pages. Please read about LayoutCollector and
LayoutEnumerator from here:
https://reference.aspose.com/words/net/aspose.words.layout/layoutenumerator/
https://reference.aspose.com/words/net/aspose.words.layout/layoutcollector/

Please use the following code example to achieve your requirements. Hope this helps you.

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

LayoutCollector layoutCollector = new LayoutCollector(doc);
LayoutEnumerator layoutEnumerator = new LayoutEnumerator(doc);

var collection = doc.GetChildNodes(NodeType.Shape, true);
foreach (Shape shape in collection)
{
    var renderObject = layoutCollector.GetEntity(shape);
    layoutEnumerator.Current = renderObject;
    RectangleF location = layoutEnumerator.Rectangle;
    int page = layoutEnumerator.PageIndex;
}