u/jonas1ara

I wanted to learn Rust, so I built Glance: an open-source WinUI 3 (.NET 10) + Rust hybrid PDF reader for Windows 11.
▲ 1 r/csharp+2 crossposts

I wanted to learn Rust, so I built Glance: an open-source WinUI 3 (.NET 10) + Rust hybrid PDF reader for Windows 11.

Hey everyone,

I've been wanting to learn Rust for a while, and I finally decided to dive in by building a practical project: Glance, a fast, lightweight, and native PDF viewer designed for Windows 11. It's completely open-source (MIT license).

Instead of using a resource-heavy framework like Electron or going pure C#, I went with a hybrid architecture to combine the modern Fluent UI capabilities of .NET with the systems-level speed and safety of Rust.

The Stack & Architecture:

  • Frontend: WinUI 3 (.NET 10) leveraging native Mica backdrops, dynamic light/dark theme support, and virtualized scroll grids.
  • Backend (Rust): Google's PDFium library accessed through a raw Rust wrapper (pdfium-render). Rust handles the heavy lifting: document loading, page rendering to bitmaps, and annotation processing.
  • Bridge (FFI): A custom P/Invoke layer. All unmanaged FFI calls are offloaded to background threads using a custom asynchronous task bridge to keep the WinUI main thread buttery smooth (60fps scrolling).
  • Self-Contained MSIX: The installer bundles both the .NET Runtime and Windows App SDK binaries internally, making the app zero-dependency for end-users (no extra runtime prompts).

Key Features Implemented:

  • Side-by-side Split View: Compare two PDFs simultaneously with synchronized scrolling.
  • Visual Welcome Screen: An Evince-style welcome grid showing cover-page thumbnails rendered on the fly.
  • Anotations & Ink: Digital ink drawing for signatures (using a rounded pen pointer), text highlights, and floating sticky notes.
  • Local Persistence: Annotations automatically serialize to a local JSON cache on pointer release with a fully-functional Ctrl + Z undo stack.

Lessons Learned (C# ↔ Rust FFI):

Writing FFI code between a garbage-collected runtime like .NET and a memory-safe language like Rust was the most challenging and rewarding part of this project. I had to learn how to:

  1. Safely marshal complex structures and UTF-8 string pointers across the boundary.
  2. Implement a DllImportResolver to locate and load native binaries dynamically.
  3. Manage memory lifetimes carefully—specifically ensuring native Rust allocations (like page and document pointers) are freed correctly on the Rust side (memory_free) rather than letting the .NET GC touch them.

The code is fully open-source and I would love any feedback on the FFI structure or code design:

https://github.com/jonas1ara/Glance

github.com
u/jonas1ara — 11 hours ago
▲ 0 r/csharp+1 crossposts

Genera representaciones impresas de CFDIs 4.0 con el diseño del SAT en .NET

NubeFiscal.PdfGenerator — Genera representaciones impresas de CFDIs 4.0 del SAT en .NET

GitHub: https://github.com/Nube-Fiscal/NubeFiscal.PdfGenerator

NuGet: https://www.nuget.org/packages/NubeFiscal.PdfGenerator

Implementación desde cero usando QuestPDF + .NET 10. Sin servicios externos, sin API Keys de pago — solo C#, el XML de tu CFDI y el diseño oficial del SAT.


Tipos de comprobante soportados

  • Ingreso (I) — múltiples conceptos, descuentos, IVA por tasa
  • Egreso (E)
  • Traslado (T)
  • Pago — Complemento de Pago 2.0 (P)
  • Nómina — Complemento de Nómina 1.2 (N)
  • Comprobantes cancelados con fecha de cancelación
  • CFDI 3.3 (compatibilidad)

Inicio rápido

dotnet add package NubeFiscal.PdfGenerator
var cfdi     = CfdiXmlParser.FromXml(xmlContent);
var pdfBytes = PdfBuilder.Construir(cfdi);

Repositorio

https://github.com/Nube-Fiscal/NubeFiscal.PdfGenerator


Motivación

Trabajando en proyectos propios de facturación necesitaba generar las representaciones gráficas de CFDIs. El problema: ninguna librería gratuita las generaba con el diseño oficial del SAT. La mayoría te obliga a pagar un servicio externo y esperar que te liberen una API Key.

Lo construí desde cero y lo libero como open source para que cualquier desarrollador en México pueda usarlo sin depender de terceros.

PRs bienvenidas.

github.com
u/jonas1ara — 17 days ago