Export rtf to string

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

    Posted 27 Mar 2016 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
    2056 posts

    Posted 28 Mar 2016 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. Peter
    Peter avatar
    2 posts
    Member since:
    Mar 2016

    Posted 28 Mar 2016 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

  4. Dess
    Admin
    Dess avatar
    2056 posts

    Posted 29 Mar 2016 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.
  5. Evelyn
    Evelyn avatar
    1 posts
    Member since:
    Mar 2017

    Posted 31 Mar in reply to Dess Link to this post

    RadRichTextEditor Como obtener el texto con el formato de texto y guardarlo en una BD
  6. Dess
    Admin
    Dess avatar
    2056 posts

    Posted 03 Apr Link to this post

    Hello Evelyn, 

    Thank you for writing.  

    I would like to note that the official language for communication in our forum is English. Thus, the community would gladly help you with the problems you are experiencing. 

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

    Regards,
    Dess
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top