Getting rtf field from domino with java for JSON -


i trying make json save domino document. works fine, except when handling rich text format field. problem this: html editor puts newline , tabs after every html beginning tag, when try rtf in html saved, contains newlines, tabs etc. tried replacing them, nothing happened.

this how rtf looks (and can not changed):

<p>     sample text</p> 

this how i'm trying data rtf:

somestring = viewdata.getdocument().getmimeentity("myfield").getcontentastext(); 

how tried replacing newline:

somestring.replaceall("\n", ""); somestring.replaceall("\\n", ""); somestring.replaceall("\\\n", ""); 

i like

<p>some sample text</p> 

i tryed approach jsongenerator hadle me. returns json full of /t , /n chars. , had other problems jsongenerator because json has more 1 level in depth. returning string without newline , tab simpliest solution.

does have idea how solve problem?

i can imagine there might few things involved.

i suspect first 1 replaceall interprets string regular expression. using replace safer in situation; in spite of name, replaces occurrences, instead treats contents literal string.

another string contains two-character windows crlf. i'm less sure this, .replace("\r", "") sure.

finally, assigning result of replace call string variable? doesn't modify string in-place, that's common pitfall.

as aside, wary way you're getting content of mime rt field. work when content text-only, but, when attachments or embedded images added, mime structure changes , top level becomes multipart/related or multipart/mixed entity , content moved child. safest way seek body content depth-first recursive search first mimeentity getcontenttype() text , getcontentsubtype() html.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -