PDF Split in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to split one PDF document to multiple PDF documents.

(NO screenshot)

using System;
using Spire.Pdf;

namespace SplitDocument
{
    class Program
    {
        static void Main(string[] args)
        {
            //open pdf document
            PdfDocument doc = new PdfDocument(@"Sample3.pdf");

            String pattern = "SplitDocument-{0}.pdf";
            doc.Split(pattern);

            String lastPageFileName
                = String.Format(pattern, doc.Pages.Count - 1);

            doc.Close();

            //Launching the Pdf file.
            System.Diagnostics.Process.Start(lastPageFileName);
        }
    }
}

Imports Spire.Pdf

Namespace SplitDocument
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'open pdf document
            Dim doc As New PdfDocument("Sample3.pdf")

            Dim pattern As String = "SplitDocument-{0}.pdf"
            doc.Split(pattern)

            Dim lastPageFileName As String = String.Format(pattern, doc.Pages.Count - 1)

            doc.Close()

            'Launching the Pdf file.
            Process.Start(lastPageFileName)
        End Sub
    End Class
End Namespace