Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

License

NotificationsYou must be signed in to change notification settings

solid-company/wrappers

Repository files navigation

SolidCompany.Wrappers.WkHtmlToImage is a .NET Core wrapper for a part of an open-source projectwkhtmltopdf which iswkhtmltoimage. It supports converting an HTML to images in a selected format.

Get Packages

You can getSolidCompany.Wrappers.WkHtmlToImage package bydownloading 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:

publicvoidConfigureServices(IServiceCollectionservices){// ...services.AddHtmlToImageConversion();// ...}

Now you are free to use this powerful tool by injectingIHtmlToImage into a constructor:

publicclassSampleService{privatereadonlyIHtmlToImagehtmlToImage;publicSampleService(IHtmlToImagehtmlToImage){this.htmlToImage=htmlToImage;}publicasyncTask<Stream>ConvertHtmlToImageAsync(stringhtml,intwidthPx){returnawaithtmlToImage.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=newApplicationInsightsDependencyLogger(serviceProvider.GetRequiredService<TelemetryClient>());options.ExecutionTimeout=TimeSpan.FromMinutes(2);options.ExectuionDirectory=newCustomDirectory("C:/Temp");});

DependencyLogger allows to track every wkhtmltoimage call withAzure Application Insights. To use it you needSolidCompany.Wrappers.Logging.ApplicationInsights package.

ExecutionTimeout lets you specify a maximumwkhtmltoimage 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.

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp