HtmlCssToImage.DependencyInjection 0.0.9

dotnet add package HtmlCssToImage.DependencyInjection --version 0.0.9
                    
NuGet\Install-Package HtmlCssToImage.DependencyInjection -Version 0.0.9
                    
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="HtmlCssToImage.DependencyInjection" Version="0.0.9" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HtmlCssToImage.DependencyInjection" Version="0.0.9" />
                    
Directory.Packages.props
<PackageReference Include="HtmlCssToImage.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 HtmlCssToImage.DependencyInjection --version 0.0.9
                    
#r "nuget: HtmlCssToImage.DependencyInjection, 0.0.9"
                    
#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 HtmlCssToImage.DependencyInjection@0.0.9
                    
#: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=HtmlCssToImage.DependencyInjection&version=0.0.9
                    
Install as a Cake Addin
#tool nuget:?package=HtmlCssToImage.DependencyInjection&version=0.0.9
                    
Install as a Cake Tool

HTML/CSS to Image

.NET / C# Client - Dependency Injection

HCTI Logo

This package provides dependency injection support for the HtmlCssToImage client.

NuGet Version

Getting Started

Installation

Add the package to your project:

dotnet add package HtmlCssToImage.DependencyInjection

Registering the IHtmlCssToImageClient in your application's startup

(usually Program.cs or Startup.cs)

You can provide your API Id and Key directly or using standard dotnet Configuration.

Direct Configuration

If you want to provide your API Id and Key directly, you can do so by calling AddHtmlCssToImage in your Program.cs or Startup.cs - this may be useful for testing purposes locally, but it is not recommended to use plain text credentials in your source code in production.

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        builder.Services.AddHtmlCssToImage("api_id", "api_key");
    }
}
Action-based Configuration

To provide your API Id and Key using an action, you can call AddHtmlCssToImage in your Program.cs or Startup.cs and pass in an action that will be invoked to retrieve your API Id and Key.

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        builder.Services.AddHtmlCssToImage(options =>
        {
            options.ApiId = Environment.GetEnvironmentVariable("HCTI_API_ID")!;
            options.ApiKey = Environment.GetEnvironmentVariable("HCTI_API_KEY")!;
        });
    }
}
Standard dotnet Configuration
public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        builder.Services.AddHtmlCssToImage(builder.Configuration.GetSection("HCTI"));
    } 
}

You can also simply pass a string to the AddHtmlCssToImage method to bind to a configuration section.

public class Program
{
    public static void Main(string[] args)
    {
        var builder = WebApplication.CreateBuilder(args);
        builder.Services.AddHtmlCssToImage("HCTI");
    } 
}

In either case, your configuration would look like this:

{
  "HCTI":{
    "ApiId": "api_id",
    "ApiKey": "api_key"
  }
}

See HtmlCssToImageOptions.cs for the Configuration object

HTTP Options

Because the HtmlCssToImage client is added to the DI container as a typed HTTP Client (see Microsoft Docs) it means you can extend its default behavior, such as adding retry policies or logging.

All the .AddHtmlCssToImage() methods return an IHttpClientBuilder which allows you to configure the underlying HttpClient instance.

Performance & Native AOT

This library is built with performance in mind and is fully compatible with Native AOT (Ahead-of-Time) compilation in .NET 9+.

The client internally uses source-generated JSON serialization, so no extra configuration is required for standard API requests.

The configuration binding source generator is enabled, so you can safely use the IConfiguration overload of AddHtmlCssToImage without any additional configuration. You still need to ensure that the PublishAot flag is enabled in your project file.


Check out the HTML/CSS To Image Docs for more details on the API's capabilities.

Get started for free at htmlcsstoimage.com.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on HtmlCssToImage.DependencyInjection:

Package Downloads
HtmlCssToImage.Blazor

Official Blazor integration for HTML/CSS to Image API. Add automated OG meta tags to your pages.

HtmlCssToImage.TagHelpers

Official Tag Helpers for HTML/CSS to Image API. Add automated OG meta tags to your pages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.0.9 34 1/9/2026
0.0.8 43 1/7/2026
0.0.7 39 1/6/2026
0.0.6 39 1/6/2026
0.0.5 36 1/6/2026
0.0.4 39 1/6/2026