docx Template Docx4j replacing text in Java

后端 未结 2 764
情书的邮戳
情书的邮戳 2021-01-26 07:01

Im new to Docx4j and my task is to replace some Text of a docx Template. I read the getting Started Guide of docx4j but I don\'t think I fully understood the whole concept. Well

2条回答
  •  长情又很酷
    2021-01-26 07:17

    The placeholder search and replace code built in to docx4j works just fine, but if you're having issues with placeholders getting broken up by rsid entities, you need to ensure that you have grammar and spell-checking disabled when saving your "template" (i.e. source) document. This will help prevent your text runs becoming fragmented (note that you might want to disable proof-reading too, as that inserts bookmark tags here there and everywhere).

    Once you've done the search and replace and have a new / updated document, you can re-enable spell-checking easily enough. This thread has more on RSIDs: turnoff rsid's spell check & grammar check in generated xml

提交回复
热议问题