locked
getting Text from RTF document RRS feed

  • Question

  • (Windows Store Apps using C#)

    Hi,

    I have the rtf document stored into a byte array.

    (since I encrypted and stored the rtf doc, while retrieving it I have to decrypt it. I get bytes from the decrypter.)

    I just need to get the text of the document from the byte array, I dont need to show all the formatted content and images.

    Is there any way to do it...

    Thanks.

    Thursday, July 11, 2013 4:57 PM

Answers

  • Load it into a non-visible RichEditBox and then extract it out with RichEditBox.Document.GetText()

    RTF is pretty easy to parse if you don't care about rendering, so you also could go through and dump the formatting tags.

    --Rob

    Thursday, July 11, 2013 6:28 PM
    Moderator

All replies

  • Load it into a non-visible RichEditBox and then extract it out with RichEditBox.Document.GetText()

    RTF is pretty easy to parse if you don't care about rendering, so you also could go through and dump the formatting tags.

    --Rob

    Thursday, July 11, 2013 6:28 PM
    Moderator
  • Hello,

    You could try a .NET component called Spire.Doc component. It can get all text from RTF document in the easiest and fastest way. Share the below code snippet. Hope it can help you.

    Document document = new Document();
    document.LoadRtf(@"D:\sample.rtf");
    string text= document.GetText();


    Thursday, July 25, 2013 3:04 AM
  • Thanks for the suggestion, QianQ, but the Spire.Doc component isn't available for Windows Store apps and wouldn't be any easier than using the in-box RichEditBox control.

    --Rob

    Thursday, July 25, 2013 3:37 AM
    Moderator