SolidCompany.Wrappers.WkHtmlToImage
1.4.1
Prefix Reserved
dotnet add package SolidCompany.Wrappers.WkHtmlToImage --version 1.4.1
NuGet\Install-Package SolidCompany.Wrappers.WkHtmlToImage -Version 1.4.1
<PackageReference Include="SolidCompany.Wrappers.WkHtmlToImage" Version="1.4.1" />
<PackageVersion Include="SolidCompany.Wrappers.WkHtmlToImage" Version="1.4.1" />
<PackageReference Include="SolidCompany.Wrappers.WkHtmlToImage" />
paket add SolidCompany.Wrappers.WkHtmlToImage --version 1.4.1
#r "nuget: SolidCompany.Wrappers.WkHtmlToImage, 1.4.1"
#:package SolidCompany.Wrappers.WkHtmlToImage@1.4.1
#addin nuget:?package=SolidCompany.Wrappers.WkHtmlToImage&version=1.4.1
#tool nuget:?package=SolidCompany.Wrappers.WkHtmlToImage&version=1.4.1
SolidCompany.Wrappers.WkHtmlToImage is a .NET Core wrapper for a part of an open-source project wkhtmltopdf which is wkhtmltoimage. It supports converting an HTML to images in a selected format.
Get Packages
You can get SolidCompany.Wrappers.WkHtmlToImage package by downloading it from NuGet feed.
Getting Started
SolidCompany.Wrappers.WkHtmlToImage easily integrates with .NET Core Dependency Injection. You need only one line of code to get everything working:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddHtmlToImageConversion();
// ...
}
Now you are free to use this powerful tool by injecting IHtmlToImage into a constructor:
public class SampleService
{
private readonly IHtmlToImage htmlToImage;
public SampleService(IHtmlToImage htmlToImage)
{
this.htmlToImage = htmlToImage;
}
public async Task<Stream> ConvertHtmlToImageAsync(string html, int widthPx)
{
return await htmlToImage.CreateImageAsync(html, widthPx, ImageFormat.Png);
}
}
Image height is automatically scaled to width which preserves a valid ratio.
Configuration
You can pass a few additional options to configuration:
services.AddHtmlToImageConversion((serviceProvider, options) =>
{
options.DependencyLogger = new ApplicationInsightsDependencyLogger(serviceProvider.GetRequiredService<TelemetryClient>());
options.ExecutionTimeout = TimeSpan.FromMinutes(2);
options.ExectuionDirectory = new CustomDirectory("C:/Temp");
});
DependencyLogger allows to track every wkhtmltoimage call with Azure Application Insights. To use it you need SolidCompany.Wrappers.Logging.ApplicationInsights package.
ExecutionTimeout lets you specify a maximum wkhtmltoimage execution time. Default is 30 seconds.
ExectuionDirectory specifies where the exe file is run and where temporary files are created. By default %TEMP%\SolidCompany.Wrappers.WkHtmlToImage directory is used.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 5.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 5.0.0)
- SolidCompany.Wrappers.Logging.Abstractions (>= 1.4.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.