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";
doc.LastSection.Body.LastParagraph.AppendChild(newShape);
doc.save("file.doc");
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
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);
doc.Save(@"Test067\out.doc");