Free Support Forum - aspose.com

How to import only referenced images?

Hi,

Please look attached word file.

This is reference document. I want to import data between [IMAGE] and [/IMAGE]. How to import only this image from another document? I dont want to import all images from reference document.

Thanks,

Hemant

Hi

Thanks for your request. I think that you can try to use the following code to achieve this.

Document doc = new Document(@"323_100891_isrc\in.doc");

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

foreach (Shape shape in shapes)

{

//if previouse paragraph is [IMAGE] then save image

if (shape.ParentParagraph.PreviousSibling.Range.Text.Contains("[IMAGE]"))

{

shape.ImageData.Save(@"323_100891_isrc\test.jpg");

}

}

I hope that this will help you.

Best regards.