🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

SolidCompany.Wrappers.WkHtmlToImage

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

SolidCompany.Wrappers.WkHtmlToImage

.NET Core wrapper for wkhtmltoimage

1.4.1
NuGet
Version published
Maintainers
1
Created
Source

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.

Keywords

wkhtmltoimage

FAQs

Package last updated on 21 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts