Parse color information from rich text

I've seen many topics covering how to embed color information into rtf strings. Ok, no problem there. I would like to know how to parse color information out of an rtf string. Specifically, when looping through an "for rt in rp do" loop, can I determine what the color is for the rt text?

You ask: why would you want to do this? We have code and I've seen a few iterations of code that exports modules to html but they never seem to export the text color information. So ultimately I'm trying to convert colored rtf text when exporting it to html.

Thanks,
Rob


Rob_S - Mon Sep 22 09:17:41 EDT 2014

Re: Parse color information from rich text
Wolfgang Uhr - Mon Sep 22 10:50:01 EDT 2014

Hi

If you want to convert a rich text string to html, forget everything about rich text parsing

  1. read the rich text string from the attribute (feel free to use richTextWithOle)
  2. write this string to a temporary file and use the extension .rtf
  3. Open this file with word
  4. save the data as html or as *.docx-file (this is a compressed xml-file)
  5. pick out the data you need by using a html or an xml parser

The only thing you have to use dxl, is to read the attribute. All the other things you can do in other languages.

Best regards

Wolfgang

Re: Parse color information from rich text
llandale - Mon Sep 22 15:58:14 EDT 2014

Don't know anything about HTML, but maybe it is missing a color table?  The rich text chunks will say "the following is in color #5" and the color table resolves it. 

  • RT color table looks like this: "{\\colortbl ;\\red255\\green0\\blue0;\\red60\\green200\\blue60;\\red60\\green60\\blue200;}"; 3 colors defined.

No, the "rt" properties are limited in DXL.

-Louie