We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Change default language of document

Hi there, while creating a new Word document from scratch I realized that the output file has the language set to United States English on All Paragraphs and Tables.
While debugging I saw that the system's current culture is set to pt-PT and that's the one I wanted to be.

What property do I need to change so the entire document defaults to Portuguese?

Thank you!



1 Reply

SB Suriya Balamurugan Syncfusion Team February 2, 2023 04:19 PM UTC

Pedro, from the given details, we have found that your requirement is to set the proofing language to text in the Word document. To achieve your requirement, we suggest you to set the required language (LocaleIDs) in the LocaleIdASCII property of the text character format as shown below,

//Creates a new Word document.

using (WordDocument document = new WordDocument())

{

    //Add new section to the document.

    IWSection section = document.AddSection();

    //Add new paragraph to the section.

    IWParagraph paragraph = section.AddParagraph();

    //Add new text to the paragraph.

    IWTextRange text = paragraph.AppendText("This is the first text range. ");

    //Set language identifier.

    text.CharacterFormat.LocaleIdASCII = (short)LocaleIDs.pt_PT;

    //Creates file stream.

    using (FileStream outputFileStream = new FileStream(Path.GetFullPath(@"../../../Result.docx"), FileMode.Create, FileAccess.ReadWrite))

    {

        //Saves the Word document to file stream.

        document.Save(outputFileStream, FormatType.Docx);

    }

}


We have prepared the sample application to set the Portuguese as a proofing language to text in the Word document and it can be downloaded from the below attachment.

Refer our UG documentation to know more about working with text in the Word document,
https://help.syncfusion.com/file-formats/docio/working-with-paragraph#working-with-text

If this post is helpful, please consider accepting it as the solution so that other members can locate it more quickly.


Attachment: Setproofinglanguage_57789fe3.zip

Loader.
Up arrow icon