Page 1 of 1

Word token substitution

PostPosted: Fri Feb 10, 2012 3:35 am
by mima
Hello all.

I have just used the docx4j lib for the first time. I need to replace tokens in a Word document and have looked at the sample UnmarshallFromTemplate which really does what I would like to do.
However I have seen some strange behaviour when editing the Word document - a task I would like to allow my end users to be able to do.

Certain changes to the Word document seem to "break" the tokens and docx4j no longer does the substitution. I'm guessing this has to do with how Word internally represents (and saves) the document, and suddenly a "text" is no longer a single text object in docx4j.

However it is impossible for the end users to see this because the document tokens look fine in Word.

Does anyone have any thoughts on this - any way around it?

Thanks.

Regards
Michael

Re: Word token substitution

PostPosted: Fri Feb 10, 2012 8:02 am
by jason
Word's tendency to split text runs amounts to an inherent drawback of the substitution approach.

That's why I recommend content control data binding instead.

That said, you can make things work a bit better if you turn off grammar and spelling markup, and rsid's; see further docx-java-f6/turnoff-rsid-s-spell-check-grammar-check-in-generated-xml-t46.html