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

Free Support Forum - aspose.com

Inserting a linked-only image into a doc

(Using Aspose 4.3.1)

Hi Aspose,

I can’t manage to insert a purely linked image form scratch. It looks like it always ends up in an embedded image. I use some code like

Aspose.Words.Document doc = new Aspose.Words.Document();
Aspose.Words.Drawing.Shape newShape = new Aspose.Words.Drawing.Shape(doc, Aspose.Words.Drawing.ShapeType.Image);
newShape.ImageData.SourceFullName = @“C:\myImage.gif”;

According to the documentation the image should then be a linked image but I can see no field in the saved doc. Instead the image is embedded.
What went wrong?


Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. You can insert linked image into the document using InsertField method. Linked imaged is INCLUDEPICTURE field. Please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

string fieldCode = string.Format("INCLUDEPICTURE \"{0}\" \\d", @"C:\\Temp\\1.jpg");

builder.InsertField(fieldCode, null);


But after inserting you should update fields inside the document manually (ctrl+A and F9). Also you can use macro to update fields. See the following link to learn more.


Best regards.


Thanks for your answer. I guess I found the reason: I forgot to specify the wraptype properly. After setting

newShape.WrapType = WrapType.Inline;

I could see that it was included as linked image. But maybe that is not equivalent to your code, I don't know.



Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

It is nice that you already found solution. The following code inserts image as INCLUDEPICTURE field.

Document doc = new Document();

Shape img = new Shape(doc, ShapeType.Image);

img.WrapType = WrapType.Inline;

img.ImageData.SourceFullName = @"C:\Temp\1.jpg";



if you open your document in MS Word and press Alt+F9 you will see field codes inside your document.

Best regards.