Convert linked Images to embedded

Using the MS Office Interops the code looks like what I have below. How can I accomplish this with Aspose Words? I need to Save the linked imaged with my file, update the file and break the links. Once I can figure this out I am buying the library.

for (int i = 0; i < oWord.Documents[1].InlineShapes.Count; i++)
{
    try
    {
        oWord.Documents[1].InlineShapes[i].LinkFormat.SavePictureWithDocument = true;
        oWord.Documents[1].InlineShapes[i].LinkFormat.Update();
        oWord.Documents[1].InlineShapes[i].LinkFormat.BreakLink();
    }
    catch (Exception e)
    {
        // do nothing…
    }
}

Hi Jason,

Thanks for your inquiry. Could you please attach your input and expected output Word documents here for our reference? We will then provide you more information about your query along with code.

Linked.doc has the images linked to a server via HTTP. Unlinked, I went in to the links portion of Word, updated the sourced and broke the links.

The code I provided would perform this action on an inlineshape.

-J

Hi Jason,

Thanks for sharing the documents. We are working over your query and will get back to you soon.

Hi Jason,

Please use following code example to replace linked images (FieldIncludePicture) with embedded images.

Aspose.Words.LoadOptions options = new Aspose.Words.LoadOptions();
options.PreserveIncludePictureField = true;
Document doc = new Document(MyDir + "Linked.doc", options);
DocumentBuilder builder = new DocumentBuilder(doc);
ArrayList removefields = new ArrayList();
foreach (Field field in doc.Range.Fields)
{
    Console.WriteLine(field.Type);
    if (field.Type.Equals(FieldType.FieldIncludePicture))
    {
        FieldIncludePicture includePicture = (FieldIncludePicture)field;
        Console.WriteLine(includePicture.SourceFullName);
        builder.MoveToField(includePicture, false);
        builder.InsertImage(includePicture.SourceFullName);
        removefields.Add(field);
    }
}
foreach (Field field in removefields)
{
    field.Remove();
}
doc.Save(MyDir + "Out v16.11.0.docx");

IT WORKS!
Thanks!
-J

Hi Jason,

Thanks for your feedback. It is nice to hear from you that the shared solution works at your end.

Could you please share some detail about the attachment related to error? We will then provide you more information about your query…