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

Free Support Forum - aspose.com

Lock Shape’s Anchor Point to Paragraph in Word DOCX Document using C# .NET

I need to know how to get all the shapes inside anchor?

In ms word ill get it using the below code

 shp.LockAnchor = False
 shp.Anchor.Paragraphs(1).Range.Select()

But i’m not sure how to do the same in aspose.

@senthilspi,

The Shape.AnchorLocked property can be used to specify whether the shape’s anchor should be locked or not. Secondly, the following C# code of Aspose.Words for .NET will store Shapes’ anchor Paragraph in an ArrayList:

Document doc = new Document("C:\\temp\\input.docx");

ArrayList list_Of_Anchor_Paragraphs = new ArrayList();
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
    Paragraph anchorParagraph = (Paragraph)shape.GetAncestor(NodeType.Paragraph);
    if (anchorParagraph != null)
        list_Of_Anchor_Paragraphs.Add(anchorParagraph);
}

Hi Hafeez,

Did you mean shape.GetAncestor() function will always return null if if the shape is not part of anchor?

Let me know if my understanding is correct?

@senthilspi,

If the Shape is anchored to a Paragraph (child of Paragraph) then it will not return a Null Paragraph. Please ZIP and upload your sample Word document (containing Shape for which you are receiving NULL) here for testing. We will then investigate the issue on our end and provide you more information.