Merge two RTF strings and create new sinlge RTF document

Namespace:  SautinSoft
Assembly:  SautinSoft.HtmlToRtf (in SautinSoft.HtmlToRtf.dll) Version: 7.1.4.17

Syntax

      
 C#  Visual Basic 
public string MergeRtfString(
	string rtf1,
	string rtf2
)
Public Function MergeRtfString ( _
	rtf1 As String, _
	rtf2 As String _
) As String

Parameters

rtf1
String
1st RTF document as string
rtf2
String
2nd RTF document as string

Return Value

A merged RTF document or empty string in case of merging failed

Remarks

A merged RTF document will contain 1st RTF document and next 2nd RTF document by order.



Examples

CopyMerge two RTF documents in memory using C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            // Merge two RTF documents in memory.
            // If you need more information about "HTML to RTF .Net" email us at:
            // support@sautinsoft.com.
            MergeRtfsInMemory();
        }

        public static void MergeRtfsInMemory()
        {
            SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf();

            // After purchasing the license, please insert your serial number here to activate the component.
            // h.Serial = "XXXXXXXXX";

            // Now we've both RTF documents stored in memory in String objects.
            string rtfString1 = File.ReadAllText(@"..\..\footer.rtf");
            string rtfString2 = File.ReadAllText(@"..\..\footer.rtf");

            string rtfSingle = h.MergeRtfString(rtfString1, rtfString2);

            // Save 'rtfSingle' to a file for demonstration purposes and show it.
            if (!String.IsNullOrEmpty(rtfSingle))
            {
                string singleRtfFile = "Single.rtf";
                File.WriteAllText(singleRtfFile, rtfSingle);
                System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(singleRtfFile) { UseShellExecute = true });
            }
        }
    }
}
CopyMerge two RTF documents in memory using VB.Net
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        ' Merge two RTF documents in memory.
        ' If you need more information about "HTML to RTF .Net" email us at:
        ' support@sautinsoft.com.
        MergeRtfsInMemory()
    End Sub

    Public Sub MergeRtfsInMemory()
        Dim h As New SautinSoft.HtmlToRtf()

        ' After purchasing the license, please insert your serial number here to activate the component.
        'h.Serial = "XXXXXXXXX"


        ' Now we've both RTF documents stored in memory in String objects.
        Dim rtfString1 As String = File.ReadAllText("..\footer.rtf")
        Dim rtfString2 As String = File.ReadAllText("..\footer.rtf")

        Dim rtfSingle As String = h.MergeRtfString(rtfString1, rtfString2)

        ' Save 'rtfSingle' to a file for demonstration purposes and show it.
        If Not String.IsNullOrEmpty(rtfSingle) Then
            Dim singleRtfFile As String = "Single.rtf"
            File.WriteAllText(singleRtfFile, rtfSingle)
            System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(singleRtfFile) With {.UseShellExecute = True})
        End If
    End Sub
End Module

See Also