Export rtf to string

4 posts, 0 answers
  1. Peter
    Peter avatar
    2 posts
    Member since:
    Mar 2016

    Posted 27 Mar Link to this post

    Hello,

    probably this will be a really simple and stupid question but nevertheless, I am stuck.

     

    This is what I tried to do: We store rtf in a database and are planning to use Telerik controls in the future (there is a lot of impressive software inside).

    Importing the rtf-text to RichTextEditor is quite easy. I simply put the content of the database field into a string variable and import it into RichtextEditore with this code:

    Private Sub ImportRtf()
            Dim provider As New RtfFormatProvider()
            content = CStr(DataGridView.CurrentRow.Cells(xx).Value)
            Me.RadRichTextEditor1.Document = provider.Import(content)
        End Sub

    This works perfectly.

    After editing the text in RichTextEditor I need to export the new text as rtf to a string to store it in the database. I looked over the documentation and found this:

    Public Function ExportToRtf(ByVal document As RadDocument) As String
            Dim provider As New RtfFormatProvider()
            Return provider.Export(document)
    End Function

    I tried to assign the function's return value to an another string variable:

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim content1 As String = ExportToRtf()
            MsgBox(content1)
    End Sub

    VisualStudio puts a wiggled blue line under ExportToRtf() and demanded a missing argument for the functions's parameter "document".

    Please tell me where my fault is.

    Thanks in advance.

    P. Arnold

  2. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 28 Mar Link to this post

    Hello Peter,

    Thank you for writing.

    The provided ExportToRtf method has one parameter of type RadDocument. However, you call the method without passing any parameters. It is necessary to pass the RadRichTextEditor.Document in order to export its content. Additional information regarding the export functionality is available here: http://docs.telerik.com/devtools/winforms/richtexteditor/import/export

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Peter
    Peter avatar
    2 posts
    Member since:
    Mar 2016

    Posted 28 Mar in reply to Dess Link to this post

    Hello, Dess,

    thank you for your answer.

    It was quite clear that I have to pass a parameter to the method. Unfortunately, the documentation is not as helpful as your answer was.

    Best Regards,

    P. Arnold

  5. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 29 Mar Link to this post

    Hello Peter,

    Thank you for writing back. 

    I am glad that the provided information was helpful. The referred help article demonstrates a sample method how to export the content of a RadDocument which can be used to export the content of any RadRichTextEditor. It is just necessary to call the method passing the RadRichTextEditor.Document as a parameter.

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top