How to extract / paste text in RTF string in C #

In a C # console application, I need to extract text from an RTF string, add some more text to it, and then convert it to RTF. I was able to do this using the System.Windows.Forms.RichTextBox class, but it's a little strange for me to use the Forms control in an application other than forms. Any better way to do this?

+4
source share
5 answers

Please view the discussion on this topic:

Clear RTF text

+3
source

Doing anything with RTF is quite difficult if you are not using Windows forms. As stated above, using forms is the easiest way.

You can write something yourself, but the RTF specification is rather complicated.
http://www.biblioscape.com/rtf15_spec.htm

Or you can use a DLL / ActiveX conversion object available for large numbers. http://www.sautinsoft.com/

Or - If you are doing this from Linux, there are also tools available. A quick glance casts UnRTF http://www.gnu.org/software/unrtf/unrtf.html

I did not include material to return the text to RTF, because I believe that the RTF specification correctly processes and formats the text.

+1
source

I think you just need to shake that feeling "weird." There is nothing strange about this.

+1
source

It depends on what you mean by "better." You are already using the simplest and easiest way to do this.

0
source

There is nothing wrong with using the user interface in a console application or even in a web application. Windows controls are part of the .NET Framework, so they can also be used. These controls do not have to be placed in β€œforms” to work.

Rethinking the wheel, using DLL / ActiveX / OCX and using Linux are simply not practical answers to your question. The best way ... to do what you know. In fact, efficiency and support can be used to use existing infrastructure methods, and then use the proposed alternatives.

0
source

Source: https://habr.com/ru/post/1276404/


All Articles