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

Free Support Forum - aspose.com

Keep automatic hyphenations in HTML


is there an option to keep automatic hyphenations when converting a Word document to HTML ?


Aspose.Words uses language-specific hyphenation dictionaries to get the same hyphenation as in Microsoft Word. To register a hyphenation dictionary please use the Hyphenation.RegisterDictionary method:

Hyphenation.RegisterDictionary("en-US", MyDir + "hyph_en_US.dic");

For more information please check the following topic:


thank you for your advice. I can see it supports the output as pdf.
But does it also support hyphenation when outputting Word as HTML?
Do you have an example ?

Thanks in advance ?
Kind regards



I use this example:

Document docWR = new Document(@"Hyphen.docx");

            //HtmlFixedSaveOptions opts2 = new HtmlFixedSaveOptions();
            string cssPrefix = "dm";
            HtmlFixedSaveOptions saveOptionsFixed = new HtmlFixedSaveOptions();
            saveOptionsFixed.Encoding = new UTF8Encoding(true);
            saveOptionsFixed.FontFormat = ExportFontFormat.Ttf;
            saveOptionsFixed.ExportEmbeddedCss = true;
            saveOptionsFixed.ExportEmbeddedImages = false;
            saveOptionsFixed.ExportEmbeddedFonts = true;
            saveOptionsFixed.ExportEmbeddedSvg = true;
            saveOptionsFixed.PrettyFormat = true;
            saveOptionsFixed.ResourcesFolder = "";
            saveOptionsFixed.CssClassNamesPrefix = cssPrefix;

            System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
            //Stream stream = File.OpenRead("hyph_en_US.dic");
            //Hyphenation.RegisterDictionary("en-US", stream);
            Hyphenation.Callback = new CustomHyphenationCallback();
            docWR.Save(@"output\Hyphen.html", saveOptionsFixed);

I have copied the class ‘CustomHyphenationCallback’ from the example in your help document.

But the callback will not be executed.


The problem line is docWR.UpdatePageLayout();
To get the desired result with hyphenation, please remove this line from your code.