Table of Contents

๐Ÿ‘‰ Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/document-intelligence/pdf-toolkit/encrypted_pdf_workflows

Encrypted PDF Workflows for C# .NET Applications


๐ŸŽฏ Purpose of the Demo

An interactive console app showing that every method in the LM-Kit.NET PDF toolkit accepts a password. Inspect, render, search, split, or edit a password-protected PDF, all without ever exporting an unlocked copy to disk.

All processing runs on-device.


๐Ÿ‘ฅ Industry Target Audience

  • Legal: signed contracts, NDAs, confidentiality-marked exhibits.
  • Finance: statements, KYC packets, signed disclosures.
  • Healthcare: patient records under HIPAA, lab reports.
  • HR: background checks, signed offer letters.
  • Any team ingesting password-protected PDFs into AI or document-processing pipelines.

๐Ÿš€ Problem Solved

Most PDF toolkits force you to "unlock" a file first, write an unencrypted copy to disk, and then process it. That breaks audit trails and exposes plaintext on the filesystem. The LM-Kit.NET toolkit threads a password parameter through every entry point, so the encrypted file never leaves its protected state. The demo wraps every supported call (PdfInfo, PdfRenderer, PdfSearch, PdfSplitter, PdfEditor) behind menu picks.


๐Ÿ’ป Application Overview

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

Mode What it does
Inspect PdfInfo.GetPageCountAsync + GetMetadataAsync + GetSecurityHandlerRevisionAsync with password.
Render PdfRenderer.SavePageAsPngAsync using PdfRenderOptions.Password.
Search PdfSearch.FindTextAsync with password, prompts for a query.
Extract PdfSplitter.ExtractPagesAsync with password, prompts for a page range.
Edit PdfEditor.ApplyToFileAsync keeping every-other page via a password-aware Attachment.
All Run all five end-to-end into a chosen output directory.
Quit Exit.

Every mode asks for the encrypted PDF path and password up-front, then routes through the matching SDK call. Ctrl-C cancels cleanly.

โœจ Key Features

  • Password threading: every API entry point accepts a password argument; nothing is unlocked on disk.
  • Attachment(path, name, password): one-line pattern shared by every class that consumes an Attachment.
  • PdfRenderOptions.Password: applied to every render method (PNG, JPEG, multi-page TIFF, ...).
  • Async + CancellationToken throughout.

๐Ÿง  Model

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

๐Ÿ› ๏ธ Getting Started

๐Ÿ“‹ Prerequisites

  • .NET 8.0 or later
  • A password-protected PDF (Adobe Acrobat, Foxit, or an online tool can encrypt a normal PDF for you).

โ–ถ๏ธ 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/encrypted_pdf_workflows
dotnet run

Pick a mode from the menu and follow the prompts.

Share