Merge RTF files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter

    #1

    Merge RTF files

    Does anyone has .NET library to merger RTF files?


    Thank You


    Peter


  • Nirosh

    #2
    Re: Merge RTF files

    Yes you can use the richtextbox control that comes with the .net library

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

    Comment

    • Linda Liu[MSFT]

      #3
      RE: Merge RTF files

      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:
      msdnmg@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.


      Comment

      • Peter

        #4
        Re: Merge RTF files

        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-lliu@online.mic rosoft.comwrote in message
        news:qqhxF4nqIH A.1788@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:
        msdnmg@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.
        >
        >

        Comment

        • Linda Liu[MSFT]

          #5
          Re: Merge RTF files

          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://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:
          msdnmg@microsof t.com.

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

          Comment

          • Peter

            #6
            Re: Merge RTF files

            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-lliu@online.mic rosoft.comwrote in message
            news:iOMaJtDrIH A.4304@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://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:
            msdnmg@microsof t.com.
            >
            This posting is provided "AS IS" with no warranties, and confers no
            rights.
            >

            Comment

            • Michael Justin

              #7
              Re: Merge RTF files

              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

              Comment

              • Peter

                #8
                Re: Merge RTF files


                "Michael Justin" <michael.justin @gmx.netwrote in message
                news:481d51f7$0 $11628$9b622d9e @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?"


                Comment

                • Linda Liu[MSFT]

                  #9
                  Re: Merge RTF files

                  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:



                  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:
                  msdnmg@microsof t.com.

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


                  Comment

                  • Peter

                    #10
                    Re: Merge RTF files

                    Thank you

                    I will check it out and let you know the results!


                    "Linda Liu[MSFT]" <v-lliu@online.mic rosoft.comwrote in message
                    news:A3O$mZBsIH A.4284@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:
                    >

                    >
                    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:
                    msdnmg@microsof t.com.
                    >
                    This posting is provided "AS IS" with no warranties, and confers no
                    rights.
                    >
                    >

                    Comment

                    Working...