public static void MergeFiles() { SautinSoft.HtmlToRtf h = new SautinSoft.HtmlToRtf(); // After purchasing the license, please insert your serial number here to activate the component. // h.Serial = "XXXXXXXXX"; DirectoryInfo htmlDir = new DirectoryInfo(@"..\..\"); // Array with several RTF files. string[] rtfFiles = new string[] { "footer.rtf", "footer.rtf", "footer.rtf" }; string singleRtf = String.Empty; // Let's divide RTF documents using page break. h.MergeOptions.PageBreakBetweenDocuments = true; foreach (string rtfFile in rtfFiles) { string rtfFilePath = Path.Combine(htmlDir.FullName, rtfFile); // Copy 1st RTF to 'singleRtf' if (String.IsNullOrEmpty(singleRtf)) { singleRtf = File.ReadAllText(rtfFilePath); } // Merge 2nd, 3rd .... else { singleRtf = h.MergeRtfString(singleRtf, File.ReadAllText(rtfFilePath)); } } // Save 'singleRtf' to a file only for demonstration purposes. string singleRtfPath = "Single.rtf"; File.WriteAllText(singleRtfPath, singleRtf); System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(singleRtfPath) { UseShellExecute = true }); }
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 }); } }