My previous post I encountered an issue with embedding images. however it seems that solution has stopped working.
I found an issue. If converting HTML to DOC, if one of the embedded IMG tags contains something other than an image, in my case a .pptx file, it causes the object to crash. not sure if there is a work-a-round for this. or an Option I am not aware of.
Hi Jason,
HtmlLoadOptions options = new HtmlLoadOptions();
options.PreserveIncludePictureField = true;
// HtmlLoadOptions.WebRequestTimeout
// The number of milliseconds to wait before the web request times out.
//The default value is 100000 milliseconds (100 seconds).
//options.WebRequestTimeout = 1000;
options.ResourceLoadingCallback = new HandleResourceLoading2();
Document doc = new Document(MyDir + "Report.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");