Moving an image in a document downwards

Hi,
In our application we deal with many documents. All documents will have different different images. I want to move a particular image in a document little bit downwards.
For instance let us consider there are 10 documents and in each document there is one common image let us say image a. I want to move that image a little bit downwards.
Can you let me know how i can achieve this.

Hi there,

Thanks for your inquiry. In your case, I suggest you please use ShapeBase.WrapType as WrapType.Square and ShapeBase.Top property as shown below to achieve your requirement.

Hope this helps you. If you still face, problem, please share your input document here for testing. We will then provide you more information about your query along with code.

Document doc = new Document(MyDir + "in.docx");
Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
shape.WrapType = WrapType.Square;
shape.Top = shape.Top + 10;
doc.Save(MyDir + "Out.docx");

Hi,
Thanks for your reply. But it doesnt work.
I am attatching source and destination documents.
I want to move image in source document somewhat downwards(as in destination document).
Kindly tell me how can i achieve this. And also if there are multiple images in a document , is there any way to recognize a particular image depending on its content.Kindly let me this too.

Hi there,

Thanks for your inquiry. The CompositeNode.GetChildNodes Method (NodeType, Boolean) returns a live collection of child nodes that match the specified type. In your case, I suggest you please use the Shape.AlternativeText as shown below to identify an image. Shape.AlternativeText defines alternative text to be displayed instead of a graphic.

I have attached the output document with this post for your kind reference. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "Source.doc");
// Shape shape = (Shape)doc.GetChild(NodeType.Shape, 0, true);
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
    if (shape.AlternativeText.Contains("cid:image004.gif@01CAF766.BD136450"))
    {
        shape.WrapType = WrapType.Square;
        shape.Top = shape.Top + 20;
    }
}
doc.Save(MyDir + "Out.docx");

Hi
I used the above code, but the image is not moving a bit down.
The imagetype needs to be InLine with text.

Hi there,

Thanks for your inquiry. Please check the output document in my previous post. The same code works at my side. If you are using some different document, please share that document here for testing.

Could you please try the following code example at your side and let us know how it goes on your side?

In case you are using an older version of Aspose.Words, I would suggest you please upgrade to the latest version (v14.3.0) from here:
https://releases.aspose.com/words/net

Document doc = new Document(MyDir + "Source.doc");
foreach (Shape shape in doc.GetChildNodes(NodeType.Shape, true))
{
    shape.WrapType = WrapType.Square;
    shape.Top = shape.Top + 20;
}
doc.Save(MyDir + "Out.docx");