Copy and paste into the document

Technical support for Spire.Doc

Moderator: iceblue support

Copy and paste into the document

Postby Pastor » Wed Nov 16, 2011 7:06 pm

Good afternoon! My name is Antonio and I'm from Brazil.
I wonder how do I copy the entire contents of the loaded document, create another page and paste the copied content.
It looked here on the site but could not find the solution.
Thank you!
Posts: 1
Joined: Thu Oct 27, 2011 7:38 pm

Re: Copy and paste into the document

Postby Tina.Lin » Sat Nov 19, 2011 10:25 am

Hello Pastor,

Sorry for late reply and thank you for your patience.

There is no function to copy the entire contents to another new page. You need to copy the content one by one according to different type.
The following code display how to copy plain text to another page.
Code: Select all
using Spire.Doc;
using Spire.Doc.Documents;

namespace _205CopyAndPaste
    class Program
        static void Main(string[] args)
            Document document = new Document(@"..\..\sample.docx", FileFormat.Docx2010);


            document.SaveToFile(@"..\..\result.docx", FileFormat.Docx2010);

        static private void CopyDocument(Document document)
            int secCount=document.Sections.Count;
            for(int i=0;i<secCount;i++)
                Section destSection=document.AddSection();
                Section srcSection=document.Sections[i];

                for(int j=0;j<srcSection.Paragraphs.Count;j++)
                    Paragraph srcParagraph=srcSection.Paragraphs[j];
                    Paragraph destParagraph=destSection.AddParagraph();


Please simulate the code to have a try.

Have a nice day.
Technical Support/Developer,
e-iceblue Support Team
User avatar
Posts: 152
Joined: Tue Sep 13, 2011 5:37 am

Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 0 guests