Replaces all matches of string "whatReplaceInRtf" in RTF file "rtfSourcePath" by the content of file "wherewithReplaceRtfPath".

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

Syntax

      
 C#  Visual Basic 
public int MergeAndReplaceRtfFileFromFile(
	string rtfSourcePath,
	string whatReplaceInRtf,
	string wherewithReplaceRtfPath,
	string newMergedRtfPath
)
Public Function MergeAndReplaceRtfFileFromFile ( _
	rtfSourcePath As String, _
	whatReplaceInRtf As String, _
	wherewithReplaceRtfPath As String, _
	newMergedRtfPath As String _
) As Integer

Parameters

rtfSourcePath
String
Path to source RTF file
whatReplaceInRtf
String
String which will be replaced
wherewithReplaceRtfPath
String
Path to RTF file which will be inserted into source RTF
newMergedRtfPath
String
Path to new merged RTF file. A fill will be overwritten

Return Value

0 - merged successfully
1 - can't open RTF source file
2 - can't open 'wherewithReplaceRtfPath' file
3 - merging failed
4 - can't create output file, check the output path

Remarks

Creates a new RTF file "newMergedRtfPath"



Examples

CopyInsert one RTF file inside another RTF file in C#
using System;
using System.IO;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {

            //Insert one RTF file inside another RTF file            
            //If you need more information about HTML-to-RTF Pro DLL .Net email us at:
            //support[at]sautinsoft.com

            SautinSoft.HtmlToRtf objH = new SautinSoft.HtmlToRtf();
            //objH.Serial = "XXXXXXXXXXXXXXX";


            /// <summary>
            /// Replaces all matches of string "whatReplaceInRtf" in RTF file "rtfSourcePath" by the RTF string "wherewithReplaceRtf".
            /// </summary>

            //In this example replaces all matches of "document" by the contents of file report2.rtf
            int ret = objH.MergeAndReplaceRtfFileFromFile(@"d:\report1.rtf", "document", @"d:\report2.rtf", @"d:\single.rtf");

            /// <returns>
            /// 0 - merged successfully<br />
            /// 1 - can't open RTF source file<br />
            /// 3 - merging failed<br />
            /// 4 - can't create output file, check the output path<br />
            /// </returns>
            if(ret==0 )
            {
                System.Diagnostics.Process.Start(@"d:\single.rtf");
            }
        }
    }
}
CopyInsert one RTF file inside another RTF file in VB.Net
Imports System
Imports System.IO
Imports System.Text

Module Module1
    Sub Main()
        'Insert one RTF file inside another RTF file            
        'If you need more information about HTML-to-RTF Pro DLL .Net email us at:
        'support[at]sautinsoft.com


        Dim objH As New SautinSoft.HtmlToRtf
        'objH.Serial = "XXXXXXXXXXXXXXX";



        ''' <summary>
        ''' Replaces all matches of string "whatReplaceInRtf" in RTF file "rtfSourcePath" by the RTF string "wherewithReplaceRtf".
        ''' </summary>


        'In this example replaces all matches of "document" by the contents of file report2.rtf
        Dim ret As Integer = objH.MergeAndReplaceRtfFileFromFile("d:\report1.rtf", "document", "d:\report2.rtf", "d:\single.rtf")

        ''' <returns>
        ''' 0 - merged successfully<br />
        ''' 1 - can't open RTF source file<br />
        ''' 3 - merging failed<br />
        ''' 4 - can't create output file, check the output path<br />
        ''' </returns>
        If ret = 0 Then
            System.Diagnostics.Process.Start("d:\single.rtf")
        End If
    End Sub
End Module

See Also