My previous post I encountered an issue with embedding images. however it seems that solution has stopped working.
The attached file is an HTML based file, with some header information and a .DOC extension. it opens up in MS Word without issue. I am able to manually embed the linked images and save as a .DOCX format and everything is good. When i use the supplied code, the images are removed.
I used the inspector on a breakpoint and found that there are 0 fields in the document.
I need to be able to convert this file to .DOC(x) format and embed the images (unlink)
public static void UpdateFieldsWithAspose(String FileNameIn, String FileNameOut)
{
LoadOptions options = new LoadOptions();
options.PreserveIncludePictureField = true;
// Document doc1 = new Document(FileNameIn, options);
// doc1.Save(FileNameIn, SaveFormat.Docx);
// doc1 = null;
Document doc = new Document(FileNameIn, options);
DocumentBuilder builder = new DocumentBuilder(doc);
ArrayList removefields = new ArrayList();
foreach (Field field in doc.Range.Fields)
{
if (field.Type.Equals(FieldType.FieldIncludePicture))
{
FieldIncludePicture includePicture = (FieldIncludePicture)field;
Console.WriteLine(includePicture.SourceFullName);
builder.MoveToField(includePicture, false);
builder.InsertImage(includePicture.SourceFullName.ToLower().Replace("https:", "http:"));
removefields.Add(field);
}
}
foreach (Field field in removefields)
{
field.Remove();
}
doc.Save(FileNameOut);
}