Default language for document


Dear Sir or Madam,

We use aspose.words on two different servers (production and testing). The word outputs of production have language set to Australian while Test produces the documents with language set to US. Is there a way to set global document language or maybe you could suggest what can affect Aspose.Words in terms of producing different outputs on different servers?




You can get or set default editing language by using the LanguagePreferences.DefaultEditingLanguage Property. Sample code is as follows:

Add Japanese language to the editing languages:

LoadOptions loadOptions = new LoadOptions();
Document doc = TestUtil.Open(@"in.docx", loadOptions);
int localeIdFarEast = doc.Styles.DefaultFont.LocaleIdFarEast;
if (localeIdFarEast == (int)EditingLanguage.Japanese)
    Console.WriteLine("The document either has no any FarEast language set in defaults or it was set to Japanese originally.");
    Console.WriteLine("The document default FarEast language was set to another than Japanese language originally, so it is not overridden.");

You may also check other properties/methods of LanguagePreferences Class.


Hi Awaiz,

thank you for a prompt reply. Is there any way to apply settings to a newly created document?
mOutputDocument = new AW.Document();
We build the document from scratch on server into a stream and then server sends it to a user.

I tried this workaround:

        using (MemoryStream ms = new MemoryStream())
            mOutputDocument.Save(ms, SaveFormat.Docx);
            ms.Position = 0;
            LoadOptions loadOptions = new LoadOptions();
            mOutputDocument = new AW.Document(ms, loadOptions);
        return mOutputDocument;

but it didn’t work for me. I have uploaded both document and screenshot showing the issue.
Alex test-Annual Report-Alex (117.3 KB)




Please check if the following code resolves this issue on your end?

Document doc = new Document("D:\\Temp\\Alex test-Annual Report-Alex test-TestNewTable (2).docx");

foreach(Run run in doc.GetChildNodes(NodeType.Run, true))
    run.Font.LocaleId = 3081; // LCID 3081 for English (Australia) Locale


Output produced on our end is attached (see (82.9 KB)).


Hi Awaiz,

Thank you, it works.

But I still have a question. I was able to figure out the difference between the servers. One uses and produces output as Australian, another one uses and produces US. Looks like some settings were changed between these two releases and I wonder if it is possible to set these settings on users side? The workaround with enumerating the Runs works as I mentioned but for me it looks like a workaround rather than a solution.




Thanks for the additional information. We have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-17178. We will further look into the details of this problem and will keep you updated on the status of this issue. We apologize for your inconvenience.



Please also check the values of “System.Text.Encoding.Default.CodePage” on both servers. Are they same? This may be the reason of different behavior.



Hi Awais,

I was able to reproduce it on my local computer. Of course CodePage was the same in both cases.




Thanks for the additional information. We will keep you posted on further updates.