How vvdb-architecture/sumatrapdf works
Purpose and entry points
SumatraPDF is a native Windows multi-format document reader (PDF, EPUB, MOBI, FB2, CHM, XPS, DjVu). The primary executable initializes application state, command handling, windows, and document startup. Visual Studio solutions are the main developer entry points.
• src/SumatraPDF.cpp
• src/SumatraStartup.cpp
• vs2022/SumatraPDF.sln
Application shell and UI
The desktop shell is C++ on the Win32 API, with custom UI abstractions for windows, layout, controls, menus, tabs, toolbars, and canvas rendering. WindowInfo and TabInfo connect per-window UI state to loaded documents; commands/actions drive user operations.
• src/WindowInfo.cpp
• src/Tabs.cpp
• src/wingui/WinGui.cpp
Document-engine boundary
A common engine interface separates viewer/UI code from format-specific loaders and renderers. Engine selection/creation dispatches to MuPDF-backed formats, DjVu, images, ebooks, PostScript, CHM, and composite/multi-engine handling. This is the principal extension boundary for supported document types.
• src/EngineBase.h
• src/EngineCreate.cpp
• src/EngineMupdf.cpp
Viewing, rendering, and interaction flow
Opening a file creates an engine and display model; UI requests page rendering through a cache and canvas. Search, text selection, annotations, table of contents, and printing operate on document/engine representations rather than direct format parsers. Rendered page data is cached to support navigation and repaint.
• src/DisplayModel.cpp
• src/RenderCache.cpp
• src/Canvas.cpp
MuPDF platform core
The vendored MuPDF tree supplies the major parsing and graphics runtime: generic document APIs, PDF interpretation, raster drawing, text extraction, HTML/EPUB layout, XPS/SVG/CBZ support, fonts, color handling, and image/codec loading. Sumatra’s MuPDF adapter is the boundary between app engines and this library.
• mupdf/include/mupdf/fitz/document.h
• mupdf/source/pdf/pdf-interpret.c
• mupdf/source/fitz/draw-device.c
State, integrations, and Windows services
Preferences, file history, favorites, themes, translations, update checks, crash handling, installer/uninstaller, preview handler, and Windows Search IFilter are separate integration surfaces. Network access is limited to client concerns such as update checking; there is no server runtime in this repository.
• src/AppPrefs.cpp
• src/UpdateCheck.cpp
• src/previewer/PdfPreviewDll.cpp
Dependencies, build, and delivery
The application is primarily C/C++ built with Visual Studio 2019/2022; Go powers repository build/release automation. Vendored libraries cover font shaping/rasterization, compression/archive handling, image codecs, DjVu, color management, HTML parsing, and PDF support. Packaging includes an AppX manifest and a bundled Microsoft WebView2 SDK. CI runs through GitHub Actions; release automation includes signing and artifact upload code.
• do/main.go
• premake5.lua
• appx/SumatraPDF.appxmanifest
Main entry points: SumatraPDF.cpp Application executable · WindowInfo.cpp Window state · EngineMupdf.cpp MuPDF adapter · DisplayModel.cpp Display model
Components 21
Desktop application
Native Win32 reader shell and document viewing pipeline.
- Application executable · Initializes application state, commands, windows, and document startup.
src/SumatraPDF.cpp - Startup flow
src/SumatraStartup.cpp - Window state · Connects each viewer window to its loaded document and UI state.
src/WindowInfo.cpp - Tabs
src/Tabs.cpp - WinGui · Provides windows, layouts, controls, menus, and canvas UI abstractions.
src/wingui/WinGui.cpp - Display model · Represents the loaded document for viewing and interaction.
src/DisplayModel.cpp - Render cache · Caches rendered page data for navigation and repaint.
src/RenderCache.cpp - Canvas
src/Canvas.cpp - Preferences and history · Stores preferences, file history, favorites, themes, and translations.
src/AppPrefs.cpp - Update checker · Checks for application updates; the repository has no server runtime.
src/UpdateCheck.cpp - PDF preview handler
src/previewer/PdfPreviewDll.cpp
Document engines
Format-neutral engine boundary and dispatch.
- Engine interface · Principal extension boundary between viewer code and document formats.
src/EngineBase.h - Engine selection · Dispatches files to MuPDF, DjVu, images, ebooks, PostScript, CHM, and composite engines.
src/EngineCreate.cpp - MuPDF adapter · Adapts Sumatra's engine API to the MuPDF runtime.
src/EngineMupdf.cpp
MuPDF core
Vendored parsing, interpretation, and graphics runtime.
- MuPDF document API · Generic document abstraction used by MuPDF-backed formats.
mupdf/include/mupdf/fitz/document.h - PDF interpreter
mupdf/source/pdf/pdf-interpret.c - Raster draw device
mupdf/source/fitz/draw-device.c
Build and delivery
Visual Studio builds, Go automation, and AppX packaging.
- Visual Studio solution
vs2022/SumatraPDF.sln - Build and release automation · Builds, signs, and uploads release artifacts.
do/main.go - Premake build definition
premake5.lua - AppX package manifest
appx/SumatraPDF.appxmanifest
Connections 22
- Visual Studio solution → Premake build definition: builds from
- Premake build definition → Application executable: builds
- Build and release automation → Premake build definition: orchestrates
- Build and release automation → AppX package manifest: packages and signs
- Application executable → Startup flow: initializes
- Startup flow → Preferences and history: loads state
- Application executable → Window state: creates
- Window state → Tabs: hosts
- Window state → WinGui: uses
- Window state → Display model: owns view
- Display model → Engine selection: opens through
- Engine selection → Engine interface: returns
- MuPDF adapter → Engine interface: implements
- Engine selection → MuPDF adapter: selects for supported formats
- Display model → Render cache: requests pages
- Render cache → Canvas: supplies rendered pages
- Canvas → WinGui: renders via
- MuPDF adapter → MuPDF document API: uses
- MuPDF document API → PDF interpreter: supports PDF processing
- PDF interpreter → Raster draw device: draws through
- Application executable → Update checker: checks updates
- PDF preview handler → MuPDF adapter: renders PDFs with