RtfPipe icon indicating copy to clipboard operation
RtfPipe copied to clipboard

Parsing sub/superscript text does not work

Open ITaluone opened this issue 1 year ago • 0 comments

Hi

I am trying to convert RTF files which contains a lot of sub- and superscript parts (like Ug=0,8 W/(m2K)).

Is this somehow possible?

My code looks like following:

var rtf = File.ReadAllText(rtfFilePath);
using var w = new StringWriter();
using var md = new PlainTextWriter(w);

Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Rtf.ToHtml(rtf, md,
new RtfHtmlSettings { Indent = true, NewLineChars = "\n", NewLineOnAttributes = true, IndentChars = "\t" });

md.Flush();

return w.ToString();

After that I get it like this: Ug=0,8 W/(m2K)

EDIT: Apparently this issue is the PlainTextWriter, because if I look at the html string, the <sub> and <sup> tags are present.

ITaluone avatar Apr 25 '23 11:04 ITaluone