473,785 Members | 2,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merge RTF files

Does anyone has .NET library to merger RTF files?
Thank You
Peter
Jun 27 '08 #1
9 8287
Yes you can use the richtextbox control that comes with the .net library

--
L.W.C. Nirosh
"Peter" <cz****@nospam. nospamwrote in message
news:Ok******** ******@TK2MSFTN GP04.phx.gbl...
Does anyone has .NET library to merger RTF files?
Thank You
Peter

Jun 27 '08 #2
Hi Peter,

I have spent more than one hour searching a .NET class library to merge RTF
files but without success.

In fact, as Nirosh has suggested, a simple workaround is to use the
RichTextBox control to do what you want.

In detail,
1. Create two instances of RichTextBox in the application.
2. Call the RichTextBox.Loa dFile method to load the first RTF file into the
first RichTextBox control.
3. Select and copy the content in the first RichTextBox control to
Clipboard by calling the SelectAll and Copy methods of the RichTextBox
class.
4. Paste the content from Clipboard to the second RichTextBox control by
calling the RichTextBox.Pas te method.
5. Repeat the step2 to step4 to merge all the RTF files to the second
RichTextBox control.
6. Save the content in the second RichTextBox to a .RTF file by calling the
RichTextBox.Sav eFile method.

The following is a sample:

private void MergeRTFFiles(s tring[] rtffiles, string outputfile)
{
RichTextBox richTextBox1 = new RichTextBox();
RichTextBox richTextBox2 = new RichTextBox();

foreach (string filepath in rtffiles)
{
if (File.Exists(fi lepath))
{
richTextBox1.Lo adFile(filepath );
richTextBox1.Se lectAll();
richTextBox1.Co py();
richTextBox2.Pa ste();
}
}
richTextBox2.Sa veFile(outputfi le);
richTextBox1.Di spose();
richTextBox2.Di spose();
richTextBox1 = null;
richTextBox2 = null;
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #3
Thank You for your help!!!

But unfortunatly it does not work, it works for simple files but when files
have lines and graphics the Copy & Paste or RichTextBox goofs them up.
"Linda Liu[MSFT]" <v-****@online.mic rosoft.comwrote in message
news:qq******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

I have spent more than one hour searching a .NET class library to merge
RTF
files but without success.

In fact, as Nirosh has suggested, a simple workaround is to use the
RichTextBox control to do what you want.

In detail,
1. Create two instances of RichTextBox in the application.
2. Call the RichTextBox.Loa dFile method to load the first RTF file into
the
first RichTextBox control.
3. Select and copy the content in the first RichTextBox control to
Clipboard by calling the SelectAll and Copy methods of the RichTextBox
class.
4. Paste the content from Clipboard to the second RichTextBox control by
calling the RichTextBox.Pas te method.
5. Repeat the step2 to step4 to merge all the RTF files to the second
RichTextBox control.
6. Save the content in the second RichTextBox to a .RTF file by calling
the
RichTextBox.Sav eFile method.

The following is a sample:

private void MergeRTFFiles(s tring[] rtffiles, string outputfile)
{
RichTextBox richTextBox1 = new RichTextBox();
RichTextBox richTextBox2 = new RichTextBox();

foreach (string filepath in rtffiles)
{
if (File.Exists(fi lepath))
{
richTextBox1.Lo adFile(filepath );
richTextBox1.Se lectAll();
richTextBox1.Co py();
richTextBox2.Pa ste();
}
}
richTextBox2.Sa veFile(outputfi le);
richTextBox1.Di spose();
richTextBox2.Di spose();
richTextBox1 = null;
richTextBox2 = null;
}

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #4
Hi Peter,

Thank you for your prompt reply!
it works for simple files but when files have lines and graphics the Copy
& Paste or RichTextBox goofs them up.

The RichTextBox doesn't work well with OLE shapes, such as a line in RTF
files.

Another more robust and complex solution to your problem is to use Word
automation. You can open open the RTF files in Word at background. Select
the contents of these RTF files and paste them to a new RTF file and save
the new file.

Please refer to the following documents on how to get started with Word
automation:
http://www.codeproject.com/KB/cs/Word_Automation.aspx
http://69.10.233.10/KB/cs/Simple_Ms_...utomation.aspx
http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 27 '08 #5
Thank you for your help!

Unfortunately the application I am working on is a multi process server
application where up to 20 RTF documents can be running/creating at one
time.

"Linda Liu[MSFT]" <v-****@online.mic rosoft.comwrote in message
news:iO******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

Thank you for your prompt reply!
>it works for simple files but when files have lines and graphics the Copy
& Paste or RichTextBox goofs them up.

The RichTextBox doesn't work well with OLE shapes, such as a line in RTF
files.

Another more robust and complex solution to your problem is to use Word
automation. You can open open the RTF files in Word at background. Select
the contents of these RTF files and paste them to a new RTF file and save
the new file.

Please refer to the following documents on how to get started with Word
automation:
http://www.codeproject.com/KB/cs/Word_Automation.aspx
http://69.10.233.10/KB/cs/Simple_Ms_...utomation.aspx
http://msdn.microsoft.com/en-us/libr...05(VS.80).aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jun 27 '08 #6
Peter wrote:
I don't even know if MS Word can be automated in a background process.
Does it have to be MS Word? AFAIK there are other RTF-capable products
on the market which can be run in a server mode. (Used for example to
batch convert to PDF).

--
Michael Justin
SCJP, SCJA
betasoft - Software for Delphiâ„¢ and for the Javaâ„¢ platform
http://www.mikejustin.com - http://www.betabeans.de
Jun 27 '08 #7

"Michael Justin" <mi************ @gmx.netwrote in message
news:48******** *************** @news.freenet.d e...
Peter wrote:
>I don't even know if MS Word can be automated in a background process.

Does it have to be MS Word? AFAIK there are other RTF-capable products on
the market which can be run in a server mode. (Used for example to batch
convert to PDF).

--
Michael Justin
SCJP, SCJA
betasoft - Software for DelphiT and for the JavaT platform
http://www.mikejustin.com - http://www.betabeans.de
No it does not have to be MSWord. I would rather not use MSWord.

My original question was "Does anyone has .NET library to merge RTF files?"
Jun 27 '08 #8
Hi Peter,

Sorry for my delayed response!

I do another search and finally find a class library for RTF processing on
the codeproject web site. You may get more information about this class
library via the below link:

http://www.codeproject.com/KB/string/nrtftree.aspx

You may use this class library to combine the content of RTF files.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 27 '08 #9
Thank you

I will check it out and let you know the results!
"Linda Liu[MSFT]" <v-****@online.mic rosoft.comwrote in message
news:A3******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Peter,

Sorry for my delayed response!

I do another search and finally find a class library for RTF processing on
the codeproject web site. You may get more information about this class
library via the below link:

http://www.codeproject.com/KB/string/nrtftree.aspx

You may use this class library to combine the content of RTF files.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsof t.com.

This posting is provided "AS IS" with no warranties, and confers no
rights.


Jun 27 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4117
by: Luke Airig | last post by:
I have two xml files that I need to merge on their common field (date_time). The merged output file needs to have the date_time field and all fields from both of the two input files. I am using the Saxon xml parser. Can someone please help me to get this to work? The two xml input files follow, as well as my attempt to write the merge xsl (merge_on_date_time.xsl): lrv_1_transaction_cid_1.xml: ---------------------------- <?xml...
8
9524
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for each person for whom a mail merge letter is desired. The query reads address info from the table for each record where is true.
0
1318
by: Shrage H. Smilowitz | last post by:
Hi, I have created a setup project in vs.net, i have included several merge modules, but when i test the installation on my development machine i dont want the uninstall to remove the files that are included in the merge modules, because it remove the files necossary to for development. How can i prevent the uninstall from removing that files. I know that normal project files i can set the permanent property to true and will not be...
8
1551
by: mesterak | last post by:
I'm trying to write a text log file processor but am having significant performance issues. * On average, there are about 100-200 files to process each file being about 1MB in size. * Typically there are ~600k to 1m lines to process total. Every line in each log file typically contains a date, a time, follwed by a textual message * Unfortunately, not all log files have the same format/layout; e.g. some may have only have month/day...
8
1872
by: ilikesluts | last post by:
Hi Group, I'm new to XML, here is my question: Would it be possible to write an algorithm that takes in two XML documents with the only condition being that they have the same root element? If it is possible what would be the best technology to implement the solution (XMLDom, XSLT...)? How hard would the solution be?
1
4296
by: mjobbe | last post by:
I have an installer that requires three merge modules (ATL, CRT, and MFC), and after adding them in, I get the following warnings when I build the MSI: WARNING: Two or more objects have the same target location ('\8.0.50727.42.cat') WARNING: Two or more objects have the same target location ('\8.0.50727.42.cat')
4
7224
by: Tom Jones | last post by:
I have an application that was originally built using Visual Studio 2003 that I upgraded to Visual Studio 2005. When I attempt to build the *.msi file in the deployment project, I am getting a compile error stating that it cannot find: "C:\Program Files\Common Files\Merge Modules\Crystal_regwiz2003.msm" I am not sure where to get this file or even if it is appropriate (i.e., should there be a newer version for Visual Studio 2005).
7
7241
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking for any comments about the use of the docmd.transfertext method instead of the code Albert used for creating the text file. Also, perhaps some ideas for coding the Subject Line of each email so
0
1607
by: Claire | last post by:
Hi, I developed an application that uses Crystal Reports in visual studio 2005 then ported the whole application to VS2008. My original setup/deployment application (created within visual studio) for this project included files CrystalReportsRedist2005_x86.msm, microsoft_vc80_atl_x86.msm and policy_8_0_Microsoft_vc80_atl_x86.msm all situated in c:\program files\common files\merge modules directory. My ported application still uses dotnet...
1
14889
by: cristalink | last post by:
Hi, I have MS Visual Studio 2008 both Pro and Dev Team Edition SP1 installed. I've compiled a managed C++ .DLL which automatically had a manifest embedded, with the following dependency: "Microsoft.VC90.CRT" "9.0.21022.8" "x86". I created an MSI package with the following merge modules: "Program Files\Common Files\Merge Modules\Microsoft_VC90_CRT_x86.msm" and "policy_9_0_Microsoft_VC90_CRT_x86.msm".
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9949
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.