Table of Contents

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

PDF Pages to Image Thumbnails for C# .NET Applications


🎯 Purpose of the Demo

An interactive console app that renders the pages of a PDF to image files. Pick one of three preset profiles for the common cases (thumbnails, previews, archival), or use the custom mode to dial in zoom, format, grayscale, and page range.

All rendering runs on-device.


👥 Industry Target Audience

  • Document management systems: per-page thumbnails in document browsers.
  • Mail-room / triage: quick visual scan of incoming PDFs without opening Acrobat.
  • OCR pipelines: rasterize before feeding to a vision-language OCR model.
  • Archives: produce high-resolution grayscale TIFFs for long-term storage.
  • Search UIs: hit-highlight previews next to results.

🚀 Problem Solved

Most PDF-to-image needs fall into three buckets: cheap thumbnails for browsing, sharper previews for legibility, and high-DPI archival captures. Every workflow has the same boilerplate (zoom, format, encoder knobs, output naming). The demo collapses that into menu picks while still exposing the full encoder surface (PNG compression level, JPEG / WebP quality, etc.) via the Custom mode.


💻 Application Overview

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

Mode What it does
Thumbs 1x zoom (~72 ppi), JPEG quality 80. Cheap thumbnails for browsing.
Preview 2x zoom (~144 ppi), PNG. Legible page previews for UIs.
Archival 4x zoom (~288 ppi), TIFF. High-DPI archive output.
Custom Prompts for zoom, format, grayscale, page range.
Quit Exit.

All modes use PdfRenderer.RenderPagesAsync so pages are streamed lazily. Each ImageBuffer is written via the format-matching SaveAs* call. Output filenames are zero-padded to the page-count width.

✨ Key Features

  • PdfRenderer.RenderPagesAsync(...): async-iterator over (pageIndex, ImageBuffer).
  • PdfRenderOptions { Zoom, PixelFormat, PageRange }: universal render config.
  • Format catalog: PNG, JPEG, WebP, BMP, single-page TIFF, TGA, PNM.
  • Grayscale toggle: ImagePixelFormat.GRAY8 for compact archival output.
  • Page-range parser: "1-3,5,8-10" syntax (1-based).

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

Pick a mode from the menu and follow the prompts.

Share