Problem loading a Word file with chinese characters

Hi, I have the following implementation to convert a Word file into HTML:

using (var stream = new MemoryStream())
{
await file.CopyToAsync(stream);
stream.Position = 0;

ComponentInfo.SetLicense(ImportUtils.gemBoxSerialKey);
ComponentInfo.FreeLimitReached += (sender, e) => e.FreeLimitReachedAction = FreeLimitReachedAction.ContinueAsTrial;

var document = DocumentModel.Load(stream);

CapturerByText capturer = new CapturerByText(document, null);

// Convert the document to HTML string
var saveOptions = new HtmlSaveOptions()
{
    HtmlType = HtmlType.HtmlInline,
    EmbedImages = true,
    UseSemanticElements = false
};

string htmlName = "Exported.html";

// Save DocumentModel object to HTML (or MHTML) file.
document.Save(htmlName, saveOptions);

// Returns the content of Exported.html and then remove the file
var htmlContent = System.IO.File.ReadAllText(htmlName);
System.IO.File.Delete(htmlName);

return Ok(new { html = htmlContent, hasHeadingStyles = capturer.hasHeadingStyles(), stylesFromDoc = capturer.getStylesFromDoc() });

}

It works with most files, but I have a file with chinese characters that throws “System.InvalidOperationException: ‘Stack empty.’“ doing DocumentModel.Load(stream)

Hi! Please send the file via email on support@gemboxsoftware.com so we can investigate it.

Hi Mirel,

Please try again with this NuGet package:

Install-Package GemBox.Document -Version 2025.11.108

Does this solve your issue?

Regards,
Mauricio