Ank.DocToolkit.Extensions.DependencyInjection
0.3.3
See the version list below for details.
dotnet add package Ank.DocToolkit.Extensions.DependencyInjection --version 0.3.3
NuGet\Install-Package Ank.DocToolkit.Extensions.DependencyInjection -Version 0.3.3
<PackageReference Include="Ank.DocToolkit.Extensions.DependencyInjection" Version="0.3.3" />
<PackageVersion Include="Ank.DocToolkit.Extensions.DependencyInjection" Version="0.3.3" />
<PackageReference Include="Ank.DocToolkit.Extensions.DependencyInjection" />
paket add Ank.DocToolkit.Extensions.DependencyInjection --version 0.3.3
#r "nuget: Ank.DocToolkit.Extensions.DependencyInjection, 0.3.3"
#:package Ank.DocToolkit.Extensions.DependencyInjection@0.3.3
#addin nuget:?package=Ank.DocToolkit.Extensions.DependencyInjection&version=0.3.3
#tool nuget:?package=Ank.DocToolkit.Extensions.DependencyInjection&version=0.3.3
Ank.DocToolkit.Extensions.DependencyInjection
Dependency-injection registration for Ank.DocToolkit —
services.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 thebyte[]or write to aStream, and put the bytes wherever they belong — that keeps the injected surface free of filesystem coupling. - The per-call
allowRemoteImageDownloadargument. Remote image download is configured once, at registration, viaDocToolkitOptions— 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 isfalseunless 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 | Versions 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. |
-
net10.0
- Ank.DocToolkit (>= 0.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
-
net8.0
- Ank.DocToolkit (>= 0.2.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
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 |