Skip to content

Add .NET bindings for anydoc (native + WebAssembly) - #56

Open
junian wants to merge 4 commits into
firecrawl:mainfrom
junian:dotnet-bindings
Open

Add .NET bindings for anydoc (native + WebAssembly)#56
junian wants to merge 4 commits into
firecrawl:mainfrom
junian:dotnet-bindings

Conversation

@junian

@junian junian commented Aug 7, 2026

Copy link
Copy Markdown

This PR adds official .NET bindings for anydoc, the Rust library that converts documents (Word, PowerPoint, Excel, OpenDocument, RTF, EPUB, CSV, and PDF) to GitHub-Flavored Markdown, so C# apps can use it from both classic desktop, ASP.NET backend, and browser environments (Blazor WebAssembly).

What's included

dotnet/Firecrawl.Anydoc — native binding (non-browser)

  • csbindgen-generated P/Invoke surface over the anydoc Rust engine.
  • Bundles the engine for every supported platform (macOS, Windows, Linux × x64/arm64) via the NuGet runtimes/{rid}/native/ layout, with a custom DllImportResolver so it loads with zero extra setup.
  • Fully synchronous and async APIs: DetectFormat, DetectFormatByExtension, ToMarkdown, ToMarkdownBytes, ToDocument, plus Async variants that offload to the thread pool.
  • Instances are thread-safe and hold no disposable state.

dotnet/Firecrawl.Anydoc.Wasm — browser binding (Blazor WebAssembly)

  • Wraps the anydoc engine compiled to WebAssembly, reached through JS interop — no native platform library is loaded in the browser.
  • Async-only API (DetectFormatAsync, ToMarkdownBytesAsync, …) matching the native surface, with sync-named members throwing PlatformNotSupportedException for parity.
  • Ships as a Razor class library (_content/Firecrawl.Anydoc.Wasm/) so the glue + wasm binary flow to Blazor WASM hosts automatically.

dotnet/Firecrawl.Anydoc.Shared — shared model & types

  • The document model (Document, Block, Inline, Table, Asset, …) and common types (Format, ConvertErrorKind, AnydocException) live in one place and are compiled by both bindings, so both packages expose the identical Firecrawl.Anydoc API.

Tests & demos

  • Firecrawl.Anydoc.Tests — native binding smoke tests against the shared fixture corpus.
  • Firecrawl.Anydoc.Wasm.Tests — wasm binding tests.
  • AnydocBlazorWasmDemo — in-browser conversion demo (Blazor WebAssmebly with Fluent UI).
  • AnydocAvaloniaDemo — desktop conversion demo (Avalonia UI).

Both bindings are packed as NuGet packages (Firecrawl.Anydoc and Firecrawl.Anydoc.Wasm).

// Desktop (native)
var anydoc = new AnydocConverter();
string md = anydoc.ToMarkdown("report.docx");

// Browser (WebAssembly)
var anydoc = new AnydocConverter(jsRuntime);
string md = await anydoc.ToMarkdownBytesAsync(bytes);

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant