Ank.DocToolkit.Extensions.DependencyInjection 0.8.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Ank.DocToolkit.Extensions.DependencyInjection --version 0.8.0
                    
NuGet\Install-Package Ank.DocToolkit.Extensions.DependencyInjection -Version 0.8.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ank.DocToolkit.Extensions.DependencyInjection" Version="0.8.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ank.DocToolkit.Extensions.DependencyInjection" Version="0.8.0" />
                    
Directory.Packages.props
<PackageReference Include="Ank.DocToolkit.Extensions.DependencyInjection" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ank.DocToolkit.Extensions.DependencyInjection --version 0.8.0
                    
#r "nuget: Ank.DocToolkit.Extensions.DependencyInjection, 0.8.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ank.DocToolkit.Extensions.DependencyInjection@0.8.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ank.DocToolkit.Extensions.DependencyInjection&version=0.8.0
                    
Install as a Cake Addin
#tool nuget:?package=Ank.DocToolkit.Extensions.DependencyInjection&version=0.8.0
                    
Install as a Cake Tool

Ank.DocToolkit.Extensions.DependencyInjection

NuGet NuGet Downloads

Dependency-injection registration for Ank.DocToolkitservices.AddDocToolkit() registers six injectable interfaces over the same pure-managed HTML/DOCX/PDF/XLSX/PPTX conversion and editing logic.

dotnet add package Ank.DocToolkit.Extensions.DependencyInjection

Targets net8.0 and net10.0. MIT licensed.

Usage

using DocToolkit.Extensions.DependencyInjection;

services.AddDocToolkit();
// or, to allow remote image download for HTML->DOCX/PDF (fails in an air-gapped environment):
services.AddDocToolkit(o => o.AllowRemoteImageDownload = true);
public class InvoiceService
{
    private readonly IHtmlToDocxConverter _toDocx;
    private readonly IHtmlToPdfConverter _toPdf;

    public InvoiceService(IHtmlToDocxConverter toDocx, IHtmlToPdfConverter toPdf)
    {
        _toDocx = toDocx;
        _toPdf = toPdf;
    }

    public Task<byte[]> RenderAsync(string html) => _toPdf.ConvertAsync(html);
}
// Every interface also has Stream-based async members, so a large document never has to be
// duplicated into a caller-visible byte[] — write straight to an HTTP response body instead:
record InvoiceRequest(string Html);

app.MapPost("/invoices/pdf", async (InvoiceRequest request, IHtmlToPdfConverter toPdf, HttpResponse response) =>
{
    response.ContentType = "application/pdf";
    // The PDF is written to response.Body as it is rendered, not assembled first, so the
    // status code and headers are committed on the first write. A failure part-way through
    // cannot be turned into a clean 500 — the response is already underway.
    await toPdf.ConvertAsync(request.Html, response.Body);
});

All six interfaces — IHtmlToDocxConverter, IDocxToPdfConverter, IHtmlToPdfConverter, IDocxEditor, IWorkbookEditor, IPresentationEditor — mirror Ank.DocToolkit's static API, including both its byte[] and its Stream-based async overloads. They are registered as singletons (each wraps stateless logic) and are safe to inject and call concurrently. See the core package's README for what each one does and the offline/licensing guarantees behind them.

Two things on the static API deliberately do not appear on these interfaces:

  • The file-path helpers (ConvertToFileAsync, ConvertFile). Inject the converter, take the byte[] or write to a Stream, and put the bytes wherever they belong — that keeps the injected surface free of filesystem coupling.
  • The per-call allowRemoteImageDownload argument. Remote image download is configured once, at registration, via DocToolkitOptions — so whether an application is allowed to reach the network is a property of how it is composed, not a decision at each call site. It is false unless you opt in.

Why a separate package

A console app, Lambda or simple script that only wants the static byte[]-based API installs just Ank.DocToolkit, with zero DI dependencies. ASP.NET Core and worker-service consumers add this package too.

Licence

MIT — see the parent repository's LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.11.0 0 8/7/2026
0.10.0 0 8/7/2026
0.9.0 47 8/6/2026
0.8.0 86 8/6/2026
0.7.0 141 8/5/2026
0.6.0 95 8/4/2026
0.5.0 134 8/3/2026
0.4.0 121 8/3/2026
0.3.12 108 8/3/2026
0.3.11 98 8/3/2026
0.3.10 74 8/3/2026
0.3.9 103 8/3/2026
0.3.8 76 8/3/2026
0.3.7 106 8/3/2026
0.3.6 103 8/3/2026
0.3.5 89 8/3/2026
0.3.4 79 8/3/2026
0.3.3 68 8/3/2026
0.3.2 187 8/3/2026
0.3.1 67 8/3/2026
Loading failed