Edit :
Based on your edit the answer is a lot simpler. Just parse the file and store the individual elements together with their formatting tags.
Then create a pdf document and write out the text elements applying styles that match the original formatting tags. It's time consuming to implement but it will work.
I've done something similar a few years ago.
Alternatively you could use PDFSharp's virtual printer (or any other pdf virtual printer for that matter) to do this hassle free. Just print to PDF :)
Original Post :
You cannot have a plain text format (that's what I can assume from your question) that would have text formatting.
Tags is how formats like RTF maintain formatting in the first place. So getting rid of all tags gives you a plain text document.
However, you could have some sort of a meta file that would store the formatting data about your plain text document.
The idea is simple, you use word positions (line and column numbers) as keys to formatting tags that you will store in an xml or any other file format you want. You will end up with two files plain.txt and plain.meta.
Hope this helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…