How to read position of an image inside a paragraph text. Vb.net

Hi

As show in attached document i want to read paragraph with image , with exact position. In word we call it as layout options. I am able to read images and paragraphs individually. but i want to read as same as in my source document, with exact position of image. My requirement is read those all properties and need save in XML file.

Thanks
Anil Kasa

Hi there,

Thanks for your inquiry. 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.

We suggest you please use LayoutCollector.GetEntity method to get an opaque position of the LayoutEnumerator which corresponds to the specified node. You can use returned value as an argument to Current given the document being enumerated and the document of the node are the same.

Please use following code example to get the position of Shape node.

Dim doc As New Document(MyDir + "in.docx")
Dim layoutCollector As New LayoutCollector(doc)
Dim layoutEnumerator As New LayoutEnumerator(doc)
Dim collection = doc.GetChildNodes(NodeType.Shape, True)
For Each shape As Shape In collection
    Dim renderObject = layoutCollector.GetEntity(shape)
    layoutEnumerator.Current = renderObject
    Dim location As RectangleF = layoutEnumerator.Rectangle
    Console.WriteLine(location)
Next

Please also try EnumerateLayoutElements code example. Please get the code of “EnumerateLayoutElements” in Aspose.Words for .NET examples repository at GitHub. Hope this helps you.