Skip to content

GUI Application

Marc Jones edited this page Dec 30, 2025 · 1 revision

GUI Application

This page documents the PdfEditor graphical user interface - a cross-platform PDF viewing and redaction application built with Avalonia UI.

Overview

PdfEditor is a desktop application for viewing, editing, and securely redacting PDFs. It runs on Windows, Linux, and macOS.

Key Features:

  • Open and view PDF documents
  • Page navigation with thumbnails
  • Zoom and pan controls
  • Text selection and search
  • TRUE glyph-level redaction (removes text from PDF structure)
  • Clipboard history of redacted text
  • Batch text redaction via search
  • Page manipulation (add, remove, rotate)

Technology Stack

Component Technology Purpose
UI Framework Avalonia 11.1.3 Cross-platform XAML UI
MVVM ReactiveUI 20.1.1 Reactive bindings, commands
PDF Rendering PDFtoImage (PDFium) Page display
Graphics SkiaSharp 2D drawing

Main Window Layout

┌─────────────────────────────────────────────────────────────────┐
│  File   Edit   View   Tools   Help                    [_][□][X] │
├─────────────────────────────────────────────────────────────────┤
│ [Open] [Save] [Zoom+] [Zoom-] [Fit] │ Search: [________] [Find] │
├──────────┬──────────────────────────────────────────────────────┤
│          │                                                       │
│  Page 1  │                                                       │
│  ┌────┐  │                                                       │
│  │    │  │              PDF Page Display                         │
│  └────┘  │                                                       │
│          │              (rendered at current zoom)               │
│  Page 2  │                                                       │
│  ┌────┐  │                                                       │
│  │    │  │                                                       │
│  └────┘  │                                                       │
│          │                                                       │
│  Page 3  │                                                       │
│  ┌────┐  │                                                       │
│  │    │  │                                                       │
│  └────┘  │                                                       │
│          │                                                       │
│ Thumbs   │                                                       │
├──────────┴──────────────────────────────────────────────────────┤
│ Status: Ready                           Page 1 of 10 │ 100%     │
└─────────────────────────────────────────────────────────────────┘

Redaction Workflow

Method 1: Area Selection (Mouse)

  1. Open a PDF document
  2. Click and drag to select an area on the page
  3. Press Delete or use menu to redact
  4. Text within the area is removed from PDF structure
  5. Black box is drawn for visual confirmation
  6. Save the document

Method 2: Text Search (Batch)

  1. Open a PDF document
  2. Use Search (Ctrl+F) to find text
  3. Click "Redact All Matches"
  4. All instances are removed throughout the document
  5. Save the document

Method 3: Scripting (Automation)

See GUI-Automation for Roslyn C# scripting.

Key Files

PdfEditor/
├── Views/
│   ├── MainWindow.axaml       # XAML UI definition
│   └── MainWindow.axaml.cs    # Code-behind (event handlers)
├── ViewModels/
│   ├── MainWindowViewModel.cs           # Main logic
│   └── MainWindowViewModel.Scripting.cs # Automation support
├── Services/
│   ├── PdfDocumentService.cs    # Load/save documents
│   ├── PdfRenderService.cs      # Page rendering
│   ├── RedactionService.cs      # Redaction orchestration
│   ├── PdfSearchService.cs      # Text search
│   └── PdfTextExtractionService.cs
└── Models/
    └── PageThumbnail.cs         # Thumbnail data

MVVM Architecture

The GUI follows strict Model-View-ViewModel separation:

Layer Responsibility Example
View UI display, user input MainWindow.axaml
ViewModel State, commands, logic orchestration MainWindowViewModel.cs
Model Data structures PageThumbnail.cs
Services Business operations RedactionService.cs

Key ViewModel Properties

// Document state
public PdfDocument? CurrentDocument { get; }
public int CurrentPageNumber { get; set; }
public int TotalPages { get; }

// Display state
public Bitmap? CurrentPageImage { get; }
public double ZoomLevel { get; set; }
public ObservableCollection<PageThumbnail> Thumbnails { get; }

// Selection state
public Rect? SelectionRectangle { get; set; }
public string SearchText { get; set; }
public ObservableCollection<SearchResult> SearchResults { get; }

Key Commands

Command Action Shortcut
OpenCommand Open PDF file Ctrl+O
SaveCommand Save current document Ctrl+S
SaveAsCommand Save with new name Ctrl+Shift+S
RedactSelectionCommand Redact selected area Delete
RedactAllMatchesCommand Redact all search matches -
SearchCommand Find text Ctrl+F
ZoomInCommand Increase zoom Ctrl++
ZoomOutCommand Decrease zoom Ctrl+-
NextPageCommand Go to next page Page Down
PreviousPageCommand Go to previous page Page Up

Coordinate Systems

The GUI must convert between coordinate systems:

System Origin Y Direction Used For
PDF Bottom-left Up Content stream operations
Avalonia Top-left Down UI rendering, mouse input
Image Top-left Down Rendered page bitmaps

Conversion: When the user clicks on the rendered page, coordinates are converted:

Avalonia Y → Image Y (scaled by zoom) → PDF Y (inverted)
PDF Y = PageHeight - AvaloniaY

See PDF-Coordinate-Systems and Coordinate-Conversion-Challenges for details.

Clipboard History

Redacted text is captured to a clipboard history:

  • Shows what was removed
  • Helps verify correct content was redacted
  • Does NOT persist after closing document (security)

Error Handling

Scenario Behavior
Invalid PDF Show error dialog, don't crash
Encrypted PDF Prompt for password (if supported)
Large PDF Show progress indicator
Save failure Show error, keep document open
Redaction failure Show error, preserve original content

Keyboard Shortcuts

Shortcut Action
Ctrl+O Open file
Ctrl+S Save
Ctrl+Shift+S Save As
Ctrl+F Search
Ctrl++ Zoom in
Ctrl+- Zoom out
Ctrl+0 Reset zoom
Page Up Previous page
Page Down Next page
Home First page
End Last page
Delete Redact selection
Escape Clear selection

Platform Notes

Linux

  • Requires libgdiplus for PDF rendering
  • Install: sudo apt-get install libgdiplus

macOS

  • Notarization may be required for distribution
  • Code signing recommended

Windows

  • No special requirements
  • .NET 8.0 runtime or self-contained build

See Also

Clone this wiki locally