Converting from rich text format to plain text problems

后端 未结 2 648
轻奢々
轻奢々 2020-12-21 03:33

We currently have an application (Windows service) that connects to another of our applications and grabs invoices. In the invoices there is a RTF field for the footer/heade

相关标签:
2条回答
  • 2020-12-21 04:05

    I ended up using this. I know that it may not parse 100% of RTF text but we ran it against our live data to test it and it works fine for our purposes.

    Regex.Replace(rtfString, @"\{\*?\\[^{}]+}|[{}]|\\\n?[A-Za-z]+\n?(?:-?\d+)?[ ]?", "");
    
    0 讨论(0)
  • 2020-12-21 04:29

    I would say this is probably thrown on terminal type machines that don't have the UI libraries installed? Or possibly don't have them loaded (ie - if no user is logged in)

    It's generally not a great idea to use UI libraries in a service, because there is no guarantee that those libraries are accessible if no user is logged in.

    I would find a different way to remove the RTF formatting

    0 讨论(0)
提交回复
热议问题