Table of Contents

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

PDF Page Rotator for C# .NET Applications


🎯 Purpose of the Demo

An interactive console app that bakes per-page rotation into a PDF. The output is a real rotated PDF (not a viewer-side rotation hint), so downstream OCR, indexing, or sharing all see the corrected orientation.

All processing runs on-device.


👥 Industry Target Audience

  • Document capture / mail-room: post-process bulk scans before OCR.
  • Legal / records: clean up archive batches before long-term storage.
  • Insurance claims: customer phone uploads often arrive rotated.
  • Real estate / inspections: field-collected scans with mixed orientation.
  • Anywhere OCR accuracy matters: upright text dramatically improves recognition.

🚀 Problem Solved

Scanners deliver sideways pages. Phone uploads arrive in random orientations. Auto-correcting before OCR boosts recognition accuracy, and rotating selected pages handles the common case of a landscape foldout in an otherwise portrait document. The demo wraps PdfEditor so all three patterns are one menu pick away.


💻 Application Overview

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

Mode What it does
Auto Inspects every page via PdfInfo.GetPageInfoAsync and rotates any non-Normal page back to Normal.
All Prompts for 90 / 180 / 270 and applies that rotation to every page.
Pages Prompts for 90 / 180 / 270 and a page spec like 1,3-5,8, rotates only those pages.
Quit Exit.

Each mode builds a List<PageEdit> and hands it to PdfEditor.ApplyToFileAsync. Ctrl-C cancels cleanly.

✨ Key Features

  • PdfInfo.GetPageInfoAsync(...) for per-page orientation detection.
  • PageEdit(pageIndex, PageOrientations) as a single transform descriptor.
  • PdfEditor.ApplyToFileAsync(source, edits, output, ct) writes the rotated PDF in one pass.
  • Page spec parser: supports comma lists and hyphen ranges (1,3-5,8).

🧠 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_page_rotator
dotnet run

Pick a mode from the menu and follow the prompts.

Share