I’m using the current version of Aspose.Words to convert an mhtml file to docx:
var loadOptions = new Aspose.Words.HtmlLoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
var filePath = @"D:\DOWNLOAD\TestDocs\Msg\ADEM\50 tree top hill.mhtml";
var document = new Aspose.Words.Document(filePath, loadOptions);
document.Save(Path.ChangeExtension(filePath, ".docx"));
See downloadable input and saved output files: Files.zip
How can I save the docx file so that the images inside the mhtml are scaled property to the page (in the same way they would be when viewing the mhtml file in a browser), instead of showing half the image on the page and adding an empty page into the docx?
You can build logic on the following C# code of Aspose.Words for .NET API to fit MHTML images within the Page bounds of Word document:
var loadOptions = new Aspose.Words.HtmlLoadOptions();
loadOptions.LoadFormat = Aspose.Words.LoadFormat.Mhtml;
Document doc = new Document("C:\\temp\\Files\\50 tree top hill.mhtml", loadOptions);
ShrinkImageToFit(doc);
doc.Save("C:\\Temp\\Files\\21.3.docx");
It would be nice if Aspose.Words did this automatically, so that the MHTML file converted to Word in the same manner it views in the browser. This is a lot of work to override like this, and who knows what other sorts of graphics this will be required for?
We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-21946. We will further look into the details of this requirement and will keep you updated on the status of the linked ticket.