Language changed WordML -> DOC

Hi!

I have a question about language in Word.
I tested with the evaluation version of aspose.word .net 7.0.0 the conversion of one document from WordML to DOC (just open and save, no more).

The original WordML document has the language “German (Switzerland)” (in all paragraphs).
The converted DOC document instead has an other language, but i don’t know which (nothing ist marked). I added a picture of language settings (see attachment).
Furthermore the hyphenation is lost.

If you need i can send you the documents via email.

Thanks a lot,
Norbert

Hi Norbert,

Thanks for your inquiry. Please attach your document here for testing. I will check the issue on my side and provide you more information. Only you and Aspose staff members can download files attached in the forum.

Also, you can send your document via e-mail, as described here.
https://forum.aspose.com/t/aspose-words-faq/2711

Best regards.

Hi Norbert,

Thank you for additional information. I managed to reproduce the problem on my side. You will be notified as soon as it is resolved.

Best regards.

Hi Alexey,

is there a workaround meanwhile?
Perhaps setting the language (and the hyphenation) manually?

Thanks,
Norbert

Hi Norbert,

Thanks for your inquiry. I can suggest you two workarounds.

  1. The problem does not occur with DOC format. So you can open your document using MS Word as save it in DOC format and then process it using Aspose.Words. In this case locale options will be preserved.

  2. You can try setting localeId programmatically.
    https://reference.aspose.com/words/net/aspose.words/font/localeid/

I think the best way to achieve this is using DocumentVisitor. Please see the following code example.

Document doc = new Document(@"Test001\in.xml");
LocaleChanger changer = new LocaleChanger(2055);
doc.Accept(changer);
doc.Save(@"Test001\out.doc");

/// 
/// Class inherited from DocumentVisitor, that chnges localeId of each node to the localeId specified 
/// 
class LocaleChanger : DocumentVisitor
{
    public LocaleChanger(int localeId)
    {
        mLocaleId = localeId;
    }

    /// 
    /// Called when a FieldEnd node is encountered in the document.
    /// 
    public override VisitorAction VisitFieldEnd(Aspose.Words.Fields.FieldEnd fieldEnd)
    {
        SetLocale(fieldEnd.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a FieldSeparator node is encountered in the document.
    /// 
    public override VisitorAction VisitFieldSeparator(Aspose.Words.Fields.FieldSeparator fieldSeparator)
    {
        SetLocale(fieldSeparator.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a FieldStart node is encountered in the document.
    /// 
    public override VisitorAction VisitFieldStart(Aspose.Words.Fields.FieldStart fieldStart)
    {
        SetLocale(fieldStart.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a Footnote end is encountered in the document.
    /// 
    public override VisitorAction VisitFootnoteEnd(Footnote footnote)
    {
        SetLocale(footnote.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a FormField node is encountered in the document.
    /// 
    public override VisitorAction VisitFormField(Aspose.Words.Fields.FormField formField)
    {
        SetLocale(formField.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a Paragraph end is encountered in the document.
    /// 
    public override VisitorAction VisitParagraphEnd(Paragraph paragraph)
    {
        SetLocale(paragraph.ParagraphBreakFont);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a Run node is encountered in the document.
    /// 
    public override VisitorAction VisitRun(Run run)
    {
        SetLocale(run.Font);
        return VisitorAction.Continue;
    }

    /// 
    /// Called when a SpecialChar is encountered in the document.
    /// 
    public override VisitorAction VisitSpecialChar(SpecialChar specialChar)
    {
        SetLocale(specialChar.Font);
        return VisitorAction.Continue;
    }

    private void SetLocale(Font font)
    {
        font.LocaleId = mLocaleId;
    }

    // locale by default is English - United States
    private int mLocaleId = 1033;
}

Hope this helps.

Best regards.

Hi Alexey,

thanks for your effort,
i will test it.

Hi Alexey,

how can i use your workaround using aspose.words as COM Object? (in Perl)
Can you give me a hint?
I’ve got no idea…

Thanks,
Norbert

Hi Norbert,

Thanks for your inquiry. I think, you should create COM Wrapper in this case. Please see the following link for more information:
https://reference.aspose.com/words/net/aspose.words/comhelper/open/

Hope this could help you.

Best regards.

Hi Alexey,

your workaround works perfectly, thank you!

But i couldn’t managed it over a Com Wrapper, so it’s now an EXE
which is called with Perl. No Problem for us.

But i hope the bug will be fixed soon. It would be so much easier…

Norbert

Hi Norbert,

Thanks for your inquiry. I will let you know once the issue is resolved. Sorry for inconvenience.

Best regards.

Hi,

i saw there is a new version of Aspose.Words (8.0.0)
Is the above point fixed there?

(I didn’t get a notification, so i have to ask)

Thanks,

Norbert

Hi

Thanks for your request. Unfortunately, the issue is still unresolved. You will be notified as soon as it is fixed.

Best regards,

Hi,

one year after, i will ask again:
Is the issue now fixed?

Thanks,
Norbert

Hi Norbert,

Thanks for your inquiry.

I’m afraid this issue is still unresolved. We will inform you of any developments. Are the work arounds suggested for you previously still working in your application?

Thanks,

The issues you have found earlier (filed as WORDSNET-2891) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.