Page 1 of 1

Preserve Rich Text Formatting

PostPosted: Wed Oct 16, 2019 6:16 am
by javaDev23
When I bind a Java class (that's been converted to an XML Stream) to the content controls in a Word document template, I find that rich text formatting isn't preserved. For example, if there's a string with newlines, tabs, or bullet points, the resulting Word doc ignores these 'special' characters. We're instead left with a block of text.

How can I retain the formatting mentioned above?

Thanks.

Re: Preserve Rich Text Formatting

PostPosted: Thu Oct 17, 2019 6:28 pm
by jason
If your XML element content is a string with newlines, tabs, or bullet points, I would expect the new lines only to be handled. ValueInserterPlainTextImpl contains:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
                StringTokenizer st = new StringTokenizer(val, "\n\r\f"); // tokenize on the newline character, the carriage-return character, and the form-feed character
 
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


Regarding richer rich text, OpenDoPE data binding can handle escaped XHTML, and escaped FlatOPC XML (provided the content control tag contains a suitable hint), so those are you best options in you want real Word bullets/numbering.