public void Word(string word, int?param) { switch (word) { case "ansicpg": if (param.HasValue) { codepage = Encoding.GetEncoding(param.Value); } break; case "stylesheet": case "fonttbl": stack.Push(new VoidProcessor()); --depth; break; case "colortbl": stack.Push(colors); --depth; break; case "tab": Text('\t'); break; case "par": Text('\r'); Text('\n'); break; case "cf": nextColor = param.HasValue && param.Value != 0 ? param.Value : new int?(); break; case "highlight": nextBackground = param.HasValue && param.Value != 0 ? param.Value : new int?(); break; case "u": Text((char)param.Value); skipText = true; break; case "'": Text(codepage.GetChars(new[] { (byte)param.Value })[0]); break; } }
public static string FromRTF(string rtf, Options options = null) { using (var stringWriter = new StringWriter()) { using (var stringReader = new StringReader(rtf)) { var stack = new ProcessorStack(); var htmlRootProcessor = new HtmlRootProcessor(stack, stringWriter, options ?? new Options()); stack.Push(htmlRootProcessor); new Parser(new Scanner(stringReader), stack).Parse(); return(stringWriter.ToString()); } } }