locked
Displaying RTF text in a SSRS 2008 Report RRS feed

  • Question

  • Hello;

    I have database fields that contain RTF text. If I use the default Textbox in SSRS 2008 Report Designer, I get all the RTF formating characters, which makes for a VERY ugly report.

    Is there another control I can place on my report that will take the RTF formated text and display it properly? I can do this in Crystal Reports, but I'm converting to SSRS 2008 so I need to be able to handle RTF formated text.

    Thanks in advance for your help.
    Thanks Ron...
    Sunday, November 8, 2009 6:07 PM

Answers

All replies

  • Hi Ron:

    Third party library or create a lib and include it.  The following requires System.WindowsForm reference:

    Public Class RTFLib
        Public Function ConvertRtfToText(ByVal input As String) As String
            Dim returnValue As String = String.Empty
            Using converter As New System.Windows.Forms.RichTextBox()
                converter.Rtf = input
                returnValue = converter.Text
            End Using
            Return returnValue
        End Function
    End Class
    
    Phil

    PHuhn
    Sunday, November 8, 2009 10:10 PM
  • I am currently getting the following:
    Request for the permission of type 'System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    So, the above will have this problem.

    Phil

    PHuhn
    Monday, November 9, 2009 3:09 AM
  • Hi Ron:

    I believe a regular expression might do the trick... try
    http://stackoverflow.com/questions/188545/regular-expression-for-extracting-text-from-an-rtf-string

    Public Function ConvertRtfToTextRegex(ByVal input As String) As String
            Dim returnValue As String = String.Empty
            returnValue = System.Text.RegularExpressions.Regex.Replace(input, "\{\*?\\[^{}]+}|[{}]|\\\n?[A-Za-z]+\n?(?:-?\d+)?[ ]?", "")
            Return returnValue
    End Function
    

    Phil


    PHuhn
    • Proposed as answer by P.Huhn Tuesday, November 10, 2009 2:40 AM
    • Marked as answer by RonInOttawa Tuesday, November 10, 2009 2:14 PM
    Tuesday, November 10, 2009 2:16 AM
  • While saving you can Convert to html then,

    In SSRS report you can use HTML format to show the text from Database

    Saturday, October 10, 2015 11:26 AM