Free Support Forum - aspose.com

Wrong value in the "Left" property of a Shape

Hi Support,
If the shape is aligned to the right margin of the page, the value of the "Left" property is equal to 0.
I attached a simple example that you can see this issue:
First shape with correct value.
Second shape with wrong value.

Br,

Hi Andrea,


Thanks for your inquiry. In this case, you can use the following code to get the “Left” value of Shape nodes. The returned values will be relative to the page top left corner in points (72 point are equal to 1 inch).

Document doc = new Document(MyDir + @“Sample.docx”);

LayoutCollector collector = new LayoutCollector(doc);

LayoutEnumerator enumerator = new LayoutEnumerator(doc);

NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);

int imageIndex = 0;

foreach (Shape shape in shapes)

{

if (shape.HasImage)

{

enumerator.Current = collector.GetEntity(shape);

Console.WriteLine("Shape " + imageIndex + " - Left property value: " + enumerator.Rectangle.Left);

imageIndex++;

}

}


Hope, this helps.

Best regards,