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!
using Spire.Doc;
using Spire.Doc.Documents;
namespace _205CopyAndPaste
{
class Program
{
static void Main(string[] args)
{
Document document = new Document(@"..\..\sample.docx", FileFormat.Docx2010);
CopyDocument(document);
document.SaveToFile(@"..\..\result.docx", FileFormat.Docx2010);
System.Diagnostics.Process.Start(@"..\..\result.docx");
}
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();
destParagraph.AppendText(srcParagraph.Text);
}
}
}
}
}