Free Support Forum - aspose.com

DefaultFont.LocaleId returns Incorrect value for Empty Document using Java

Hello,
I am curious to know the difference between following statements

  1. document.getStyles().getDefaultFont().getLocaleId()
  2. builder.getFont().getLocaleId() // Where builder is of same document

For some of my word document, both gives same value
For some of my documents both statements give different values

What locale do these statements returns?

regards

@sharma.vikash.mca

StyleCollection.DefaultFont property returns document default text formatting for style ‘Default Paragraph Font’. However, DocumentBuilder.Font property returns an object that represents current font formatting properties. Please move the cursor to some text into the document and check its font properties.

To check the locale of a style, you can use Font.LocaleId property as shown below.
document.getStyles().getByStyleIdentifier(StyleIdentifier.NORMAL).getFont().getLocaleId()

To check this property, please set the language of some text as ‘German’, move the document builder cursor to this text (Run node) and get localeId. It will return you the German locale ID.

1 Like

Thank you Tahir for the clear answer,

I understood both of your points. But in one of our scnerio, we have one document that is completely Empty. The default language of the document is English (as we can see at the bottom left in the blue strip in the MS Word). so the expected value of
document.getStyles().getDefaultFont().getLocaleId() is 1033 (code for English US).

But since there is no text in the document, what should we get for
builder.getFont().getLocaleId() ? For us, we are gettiing : 1036 (code for French ).

Let us know what do you think .

Program attached

Program1.zip (9.7 KB)

@sharma.vikash.mca

We have logged this problem in our issue tracking system as WORDSNET-21656. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Could you please ZIP and attach the following template document used for your document for further investigation?
C:\Documents and Settings\changch\Desktop\spain cert\Certificate template A-Spanish v1.65.dot

I am on Windows 10. The location is not available for me.

@sharma.vikash.mca

Thanks for sharing the detail. We will inform you via this forum thread once there is an update available on this issue.