Table of Contents

👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/document-intelligence/pdf-toolkit/pdf_splitter_by_range

PDF Splitter by Page Range for C# .NET Applications


🎯 Purpose of the Demo

An interactive console app that splits one PDF into N smaller PDFs. Two modes: type custom page ranges, or pick a chunk size and let the demo split every N pages. Each part becomes a separate file in the output directory.

All processing runs on-device.


👥 Industry Target Audience

  • Regulated filings: bursting quarterly or annual filings into per-section deliverables.
  • Publishing: exporting individual chapters of a manual or e-book.
  • Legal: chopping a long contract into per-clause attachments for review.
  • Education: splitting a textbook PDF into per-lesson handouts.
  • Operations: producing audit-friendly file boundaries from a single archive PDF.

🚀 Problem Solved

Most splitting needs are repetitive: "every 10 pages", "pages 1-12, 13-40, 41-end", "one file per chapter". Doing it by hand in a viewer is slow and error-prone, and most online tools require uploading the document. The demo wraps PdfSplitter in a prompt-driven menu so the same one-line operation handles both ad-hoc and programmatic patterns.


💻 Application Overview

Interactive menu (no command-line arguments) with two modes:

Mode What it does
Ranges Prompts for ranges one per line. Syntax: 1-3, 4,6, 7-9. Blank line ends the list.
Every N pages Prompts for a chunk size. The demo enumerates 1-N, N+1-2N, ... up to the last page.
Quit Exit.

Both modes run the same pipeline: validate the source, ask for an output directory, then call PdfSplitter.SplitToFilesAsync with a Progress<PdfSplitterProgressEventArgs> callback so each output file is logged as it lands. Ctrl-C cancels cleanly.

✨ Key Features

  • PdfSplitter.SplitToFilesAsync(...) for the actual split.
  • PdfSplitterProgressEventArgs for per-part progress callbacks.
  • Range syntax: 1-based, comma-separated, hyphenated. "1-3", "1,3,5", "2-4,7".
  • Fixed-chunk mode: auto-generates the range list from the page count.

🧠 Model

  • None. This demo is pure document plumbing and does not load an LLM.

🛠️ Getting Started

📋 Prerequisites

  • .NET 8.0 or later

▶️ Running the Application

git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/document-intelligence/pdf-toolkit/pdf_splitter_by_range
dotnet run

Pick a mode from the menu and follow the prompts.

Share