Click or drag to resize

SectionStart Enumeration

Specifies type of break at the beginning of the section.

Namespace: SautinSoft.Document
Assembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.1.24
Syntax
public enum SectionStart
Members
Member nameValueDescription
NewPage0 The section starts from a new page.
NewColumn1 The section starts from a new column.
Continuous2 The new section starts on the same page as the previous section.
EvenPage3 The section starts on a new even page.
OddPage4 The section starts on a new odd page.
Example

See Developer Guide: How to merge two documents: DOCX and PDF

How to merge two documents: DOCX and PDF using C#
using System;
using System.IO;
using SautinSoft.Document;

namespace Sample
{
    class Sample
    {

        static void Main(string[] args)
        {
            // Get your free 30-day key here:   
            // https://sautinsoft.com/start-for-free/

            MergeTwoDocuments();
        }

        /// <summary>
        /// How to merge two documents: DOCX and PDF.
        /// </summary>
        /// <remarks>
        /// Details: https://sautinsoft.com/products/document/help/net/developer-guide/split-and-merge-content-net-csharp-vb.php
        /// </remarks>
        public static void MergeTwoDocuments()
        {
            // Path to our combined document.
            string singleFilePath = "Single.docx";

            string[] supportedFiles = new string[] { @"..\..\..\example.docx", @"..\..\..\example.pdf" };

            // Create single document.
            DocumentCore dcSingle = new DocumentCore();

            foreach (string file in supportedFiles)
            {
                DocumentCore dc = DocumentCore.Load(file);

                Console.WriteLine("Adding: {0}...", Path.GetFileName(file));

                // Create import session.
                ImportSession session = new ImportSession(dc, dcSingle, StyleImportingMode.KeepSourceFormatting);

                // Loop through all sections in the source document.
                foreach (Section sourceSection in dc.Sections)
                {
                    // Because we are copying a section from one document to another,
                    // it is required to import the Section into the destination document.
                    // This adjusts any document-specific references to styles, bookmarks, etc.
                    // 
                    // Importing a element creates a copy of the original element, but the copy
                    // is ready to be inserted into the destination document.
                    Section importedSection = dcSingle.Import<Section>(sourceSection, true, session);

                    // First section start from new page.
                    if (dc.Sections.IndexOf(sourceSection) == 0)
                        importedSection.PageSetup.SectionStart = SectionStart.NewPage;

                    // Now the new section can be appended to the destination document.
                    dcSingle.Sections.Add(importedSection);
                }
            }

            // Save single document to a file.
            dcSingle.Save(singleFilePath);

            // Open the result for demonstration purposes.
           System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(singleFilePath) { UseShellExecute = true });
        }
    }
}
How to merge two documents: DOCX and PDF using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document

Module Sample
    Sub Main()
        MergeTwoDocuments()
    End Sub
    ''' Get your free 30-day key here:   
    ''' https://sautinsoft.com/start-for-free/
    ''' <summary>
    ''' How to merge two documents: DOCX and PDF.
    ''' </summary>
    ''' <remarks>
    ''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/split-and-merge-content-net-csharp-vb.php
    ''' </remarks>
    Sub MergeTwoDocuments()
        ' Path to our combined document.
        Dim singleFilePath As String = "Single.docx"

        Dim supportedFiles() As String = {"..\..\..\example.docx", "..\..\..\example.pdf"}

        ' Create single document.
        Dim dcSingle As New DocumentCore()

        For Each file As String In supportedFiles
            Dim dc As DocumentCore = DocumentCore.Load(file)

            Console.WriteLine("Adding: {0}...", Path.GetFileName(file))

            ' Create import session.
            Dim session As New ImportSession(dc, dcSingle, StyleImportingMode.KeepSourceFormatting)

            ' Loop through all sections in the source document.
            For Each sourceSection As Section In dc.Sections
                ' Because we are copying a section from one document to another,
                ' it is required to import the Section into the destination document.
                ' This adjusts any document-specific references to styles, bookmarks, etc.
                '
                ' Importing a element creates a copy of the original element, but the copy
                ' is ready to be inserted into the destination document.
                Dim importedSection As Section = dcSingle.Import(Of Section)(sourceSection, True, session)

                ' First section start from new page.
                If dc.Sections.IndexOf(sourceSection) = 0 Then
                    importedSection.PageSetup.SectionStart = SectionStart.NewPage
                End If

                ' Now the new section can be appended to the destination document.
                dcSingle.Sections.Add(importedSection)
            Next sourceSection
        Next file

        ' Save single document to a file.
        dcSingle.Save(singleFilePath)

        ' Open the result for demonstration purposes.
        System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(singleFilePath) With {.UseShellExecute = True})
    End Sub
End Module
See Also