XWPF set text language

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

XWPF set text language

Hello, I would like to set the language for an XWPF document, so the end user’s spellcheck can correctly identify it.

For example, in the following method:

private void wordPara(XWPFDocument document, String text, boolean bold) {
        XWPFParagraph p = document.createParagraph();
        XWPFRun runCF = p.createRun();

I see that XWPFRun has the method getLang(), but not setLang()
What is the proper way to do this?

Thank you!
Reply | Threaded
Open this post in threaded view

Re: XWPF set text language

I raised a bug - https://bz.apache.org/bugzilla/show_bug.cgi?id=63013

It looks like a missing setter to me.

If you can create your own subclass of XWPFRun, you could try this extra

    public void setLang(String lang) {
        CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
        CTLanguage ctLang = pr.isSetLang() ? pr.getLang() : pr.addNewLang();

Sent from: http://apache-poi.1045710.n5.nabble.com/POI-User-f2280730.html

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]