Cross-platform .NET 10 printing toolkit for applications that need consistent print dialogs, previews, pagination, and job submission across Windows, macOS, and Linux.
- Unified
IPrintManagerAPI for printer discovery, session creation, preview generation, and print submission. - Platform adapters for Win32/XPS, macOS AppKit, and Linux CUPS/GTK with managed fallbacks for headless and CI runs.
- Built-in pagination, layout modes (
standard,N-up,booklet,poster), vector/PDF export via Skia, and diagnostics hooks. - Optional Avalonia UI components for page setup, preview windows, and macOS native preview hosting.
- Cross-platform harnesses and samples that validate output, metrics, and environment-specific behavior in CI.
| Scenario | Recommended package set |
|---|---|
| Avalonia app that wants automatic platform registration | PrintingTools |
| Avalonia app that also wants ready-made dialogs and preview windows | PrintingTools + PrintingTools.UI |
| Custom UI or headless workflow with direct control over the pipeline | PrintingTools.Core + one or more platform packages |
| Platform-specific integration or diagnostics work | PrintingTools.Windows, PrintingTools.MacOS, or PrintingTools.Linux directly |
| Package | Purpose |
|---|---|
src/PrintingTools.Core |
Cross-platform contracts (IPrintManager, PrintServiceRegistry), pagination/rendering pipeline, diagnostics, and option models. |
src/PrintingTools.Windows |
Win32 adapter for queue discovery, XPS/PDF export, native dialog orchestration, and job monitoring. |
src/PrintingTools.MacOS |
AppKit bridge with preview hosting (MacPreviewHost), sandbox-aware ticket handling, and Quartz PDF output. |
src/PrintingTools.Linux |
CUPS/IPP adapter that shells through lp/lpoptions, detects GTK dialogs, and supports Flatpak/Snap portals. |
src/PrintingTools.UI |
Avalonia page setup dialog, preview window, and supporting view models. |
src/PrintingTools |
AppBuilder.UsePrintingTools extension that wires the right adapter at runtime and exposes helper accessors. |
The adapters register through PrintingToolsOptions.AdapterFactory. Configure PrintServiceRegistry once during startup, or call AppBuilder.UsePrintingTools(...) in Avalonia, and then resolve the active IPrintManager through PrintServiceRegistry.EnsureManager().
| Path | Description |
|---|---|
src/ |
Library implementation projects described above. |
samples/ |
Avalonia desktop sample and platform harnesses for Windows, macOS, and Linux. |
tests/PrintingTools.Tests |
Unit tests and harness metric threshold validation. |
docs/ |
Design notes, platform guides, migration help, release-readiness notes, and feature parity tracking. |
exten/ |
Vendored prerequisites used by the samples and research branches. |
- .NET SDK 10.0.100-rc.2 with prerelease support enabled.
- Windows: Win32 spooler available and XPS support enabled.
- macOS: macOS 14+ with Xcode command line tools for building the native preview bridge.
- Linux: CUPS 2.3+,
cups-client(lp,lpoptions), and GTK 3/4 libraries for native dialog integration.
For a typical Avalonia app:
dotnet add package PrintingTools
dotnet add package PrintingTools.UIFor direct pipeline usage without the packaged UI:
dotnet add package PrintingTools.Core
dotnet add package PrintingTools.WindowsSwap the platform package as needed for macOS or Linux.
git clone https://github.com/wieslawsoltes/PrintingTools.git
cd PrintingTools
dotnet restore PrintingTool.sln
dotnet build PrintingTool.sln -c Releaseusing PrintingTools.Core;
var options = new PrintingToolsOptions
{
DiagnosticSink = evt => Console.WriteLine($"[{evt.Category}] {evt.Message}")
};
PrintServiceRegistry.Configure(options);
var manager = PrintServiceRegistry.EnsureManager();using Avalonia;
using PrintingTools;
using PrintingTools.Core;
AppBuilder.Configure<App>()
.UsePlatformDetect()
.UsePrintingTools(options =>
{
options.EnablePreview = true;
options.DefaultTicket = PrintTicketModel.CreateDefault();
})
.StartWithClassicDesktopLifetime(args);var document = PrintDocument.FromVisual(myVisual);
var request = new PrintRequest(document)
{
Options = new PrintOptions { ShowPrintDialog = true },
Ticket = PrintTicketModel.CreateDefault(),
Description = "Quarterly report"
};
var session = await manager.RequestSessionAsync(request);
var preview = await manager.CreatePreviewAsync(session);
await manager.PrintAsync(session);CreatePreviewAsync(...) returns a PrintPreviewModel that you can render in PrintingTools.UI.Controls.PrintPreviewWindow or a platform-specific preview host.
| Sample | Command | Highlights |
|---|---|---|
samples/AvaloniaSample |
dotnet run --project samples/AvaloniaSample/AvaloniaSample.csproj |
Desktop UI demonstrating preview, native dialogs, page setup, and job history. |
samples/WindowsPrintHarness |
dotnet run -c Release --project samples/WindowsPrintHarness/WindowsPrintHarness.csproj -- --output=artifacts/windows/output.pdf --metrics=artifacts/windows/metrics.json --stress=3 |
Headless smoke tests for the Win32 adapter, managed PDF export, and metrics capture. |
samples/MacSandboxHarness |
dotnet run -c Release --project samples/MacSandboxHarness/MacSandboxHarness.csproj -- --headless --output=artifacts/macos/output.pdf --metrics=artifacts/macos/metrics.json --stress=3 |
Validates AppKit bridge behavior, Quartz PDF output, and sandbox-aware diagnostics. |
samples/LinuxSandboxHarness |
GTK_USE_PORTAL=1 GIO_USE_PORTALS=1 dotnet run -c Release --project samples/LinuxSandboxHarness/LinuxSandboxHarness.csproj -- --print --output=artifacts/linux/output.pdf --metrics=artifacts/linux/metrics.json --stress=3 |
Exercises the CUPS adapter, portal-aware dialogs, and managed PDF generation for CI. |
- Documentation site: wieslawsoltes.github.io/PrintingTools
- API reference: docs/printing-api-reference.md
- Migration guide: docs/printing-migration-guide.md
- Platform notes: Windows, macOS, Linux
- Platform support matrix: docs/platform-support-matrix.md
- Sample walkthroughs: docs/printing-sample-walkthroughs.md
- Architecture and planning notes: phase2-architecture, feature-parity-matrix, wpf-printing-parity-plan
Build docs locally:
./build-docs.sh
./serve-docs.shPowerShell equivalents are available as build-docs.ps1, check-docs.ps1, and serve-docs.ps1.
ci.ymlruns cross-platform restore/build/test, executes the Windows/macOS/Linux harnesses, and validates that all NuGet packages can be packed.docs.ymlbuilds the Lunet site and publishes it to GitHub Pages on pushes to the primary branch.release.ymlruns on tags likev0.2.0, packs all six publishable libraries, verifies the macOS native bridge is present in the package, publishes to NuGet, and creates a GitHub release.- Configure
NUGET_API_KEYin repository secrets before using the release workflow for publishing.
Distributed under the terms of the MIT License.