We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert a DOC file to HTML

We are trying to convert a DOC file to an HTML using the following code:

public byte[] ConvertDocToHtml(byte[] fileContent)

{

Stream stream = new MemoryStream(fileContent);

var document = new Document(stream);

return GetFileContent(document, SaveFormat.Mhtml);

}

private static byte[] GetFileContent(Document document, SaveFormat format)

{

using (var ms = new MemoryStream())

{

document.Save(ms, format);

ms.Position = 0;

return ms.ToArray();

}

}

Sometimes this function will explode with the following exception:

.System.ArgumentException: Parameter is not valid.

at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)

at xf9a9481c3f63a419.x3cd5d648729cd9b6..ctor(Int32 width, Int32 height, Single hRes, Single vRes, PixelFormat pixelFormat)

at x077e797660ceec8d.x0a376fc3a80043f7.x2917885cd0f8f9ab()

at x077e797660ceec8d.x0a376fc3a80043f7.xba11e5f1f6087f94(Stream xcf18e5243f8d5fd3)

at x077e797660ceec8d.x0a376fc3a80043f7.x53c5cdce403a6243(x4fdf549af9de6b97 xdb732bbde4502b4e, SizeF xa03db8a5ee939042, Stream xcf18e5243f8d5fd3, ImageSaveOptions xc27f01f21f67608c)

at Aspose.Words.Rendering.ShapeRenderer.Save(Stream stream, ImageSaveOptions saveOptions)

at xf989f31a236ff98c.x31e602c0108f40dc.x878afbafb98bf640()

at x084786fe6fb0a4e7.xd42a56f5a5d721b4.xe25b4aee13041a71(xd59a0d3f8248c4e8 xd7e5673853e47af4)

at x084786fe6fb0a4e7.xd42a56f5a5d721b4.x8cac5adfe79bc025(x8556eed81191af11 x5ac1382edb7bf2c2)

at Aspose.Words.Document.xf381a641001e6830(Stream xcf18e5243f8d5fd3, String xafe2f3653ee64ebc, SaveOptions xc27f01f21f67608c)

at Aspose.Words.Document.Save(Stream stream, SaveOptions saveOptions)

The weird issue is that when restarting our service, and resending the same file, it succeeds.

We are using Aspose.Words 13.9.0.0

Have any idea what could be the problem ?

Thank you.

Hi there,


Thanks for your inquiry. Please try latest version of Aspose.Words for .NET 16.11.0. Hope this helps you.

If you still face problem, please attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.