Change font style of whole sentence in docx

余生颓废 提交于 2021-01-05 07:09:13

问题


I have been trying to change the font style of specific sentences in the docx file using Apache POI, (XWPF).

I am able to change the font style (ex.color,font family) of whole document using XWPFRun -> run.setColor(color)

but the problem is for some reaseon, it generates multiple run for a single sentence.

Example:
Sentence:  This is the sentence that has multiple run.
Run >: This is the
Run >: sentence
Run >:that has mul
Run >:tiple run
Run >: .

So, if i try to find the sentence from the file and then set the color, it does not do since the there are multiple runs for 1 sentence.

Aim : I have a JSON file from where i take the sentences and only for those sentences the font style should be changing in the docx file.

any help would be appreciated.

Out of many code, I have foud this code https://stackoverflow.com/a/63913997/13267143 for reference since it is close to what i require to do.

来源:https://stackoverflow.com/questions/65246636/change-font-style-of-whole-sentence-in-docx

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!