How to merge documents in C#

Document .Net can help you to merge documents of different formats: PDF, DOCX, RTF, Text and HTML, etc.

For example: You can combine files of the same format!
This's a simple code, how to merge file1.pdf and file2.pdf into a single PDF document.

            DocumentCore dc1 = DocumentCore.Load(@"d:\Tempos\file1.pdf");
            DocumentCore dc2 = DocumentCore.Load(@"d:\Tempos\file2.pdf");

            Section section = dc2.Sections.FirstOrDefault();
            if (section != null)
            {
                section.PageSetup.SectionStart = SectionStart.NewPage;
            }

            dc1.Content.End.Insert(dc2.Content);
            dc1.Save(@"d:\Tempos\merge.pdf");

        
See more details about Merging documents in C#.

 

© SautinSoft 2019