Parse/display RTF text in HTML?

2019-04-13 09:49发布

问题:

I'm looking to take some RTF code, such as this sample excerpt below, and displaying it in an HTML page. I don't need it to be editable, and don't want it to be at this time. In researching this I've seen plenty of RTF-capable WYSIWYG editors, but that's not really what I'm after.

{}
{\rtf1\ansi\ansicpg1252\uc1\htmautsp\deff2
    {\fonttbl{\f0\fcharset0 Times New Roman;}
    {\f2\fcharset0 Segoe UI;}
    {\f3\fcharset0 Microsoft Yi Baiti;}
}
{\colortbl\red0\green0\blue0;\red255\green255\blue255;}
\loch\hich\dbch\pard\plain\ltrpar\itap0
{\lang1033\fs18\f2\cf0 \cf0\ql{\fs24\f2 
{\loch\f3\ltrch Hello }

Is there any way to display RTF in an HTML page? Would it be better to try and parse it into HTML/CSS or is that even possible? I also considered parsing it on the .NET side, but haven't came across any solutions.

Any insight would be greatly appreciated!

回答1:

FWIW, I'm going to go with the solution found here, as it seems the most flexible.

Converting Between RTF and HTML