![]() |
VOOZH | about |
dotnet add package CoreHtmlToImage --version 2.0.0
NuGet\Install-Package CoreHtmlToImage -Version 2.0.0
<PackageReference Include="CoreHtmlToImage" Version="2.0.0" />
<PackageVersion Include="CoreHtmlToImage" Version="2.0.0" />Directory.Packages.props
<PackageReference Include="CoreHtmlToImage" />Project file
paket add CoreHtmlToImage --version 2.0.0
#r "nuget: CoreHtmlToImage, 2.0.0"
#:package CoreHtmlToImage@2.0.0
#addin nuget:?package=CoreHtmlToImage&version=2.0.0Install as a Cake Addin
#tool nuget:?package=CoreHtmlToImage&version=2.0.0Install as a Cake Tool
Cross-platform .NET library that converts HTML strings or URLs to image bytes using headless Chromium (via PuppeteerSharp). Supports Windows, Linux, and macOS.
Install-Package CoreHtmlToImage
dotnet CLI:
dotnet add package CoreHtmlToImage
Note: On first use, PuppeteerSharp automatically downloads a compatible Chromium binary (~200MB, cached for subsequent runs).
await using var converter = new HtmlConverter();
// From HTML string
var bytes = await converter.FromHtmlStringAsync("<div><strong>Hello</strong> World!</div>");
File.WriteAllBytes("image.jpg", bytes);
// From URL
var bytes = await converter.FromUrlAsync("https://example.com");
File.WriteAllBytes("image.jpg", bytes);
var options = new HtmlConverterOptions
{
Width = 800, // Viewport width (default: 1024)
Height = 600, // Viewport height (default: auto)
Format = ImageFormat.Png, // Jpg, Png, or WebP (default: Jpg)
Quality = 90, // 1-100, for Jpg/WebP (default: 100)
FullPage = true, // Capture full scrollable page (default: false)
OmitBackground = true // Transparent background for PNG/WebP (default: false)
};
var bytes = await converter.FromHtmlStringAsync(html, options);
var converter = new HtmlConverter();
var bytes = converter.FromHtmlString(html);
var bytes = converter.FromUrl("https://example.com", width: 800, format: ImageFormat.Png, quality: 90);
v2.0 replaces wkhtmltoimage with headless Chromium. Key changes:
HtmlConverter now implements IAsyncDisposable/IDisposable — use await using or using for proper cleanupFromHtmlStringAsync and FromUrlAsync are the primary APIImageFormat.WebP format optionCopyright (c) 2020 Andrei M
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 5 NuGet packages that depend on CoreHtmlToImage:
| Package | Downloads |
|---|---|
|
CHOCore.Tools
Package Description |
|
|
Wey.Framework.NetCore
基于EF Core的Code First模式的DotNetCore快速开发框架 |
|
|
IcalToImage
Generate an image of a table from a calendar. |
|
|
Wey.Framework.NetCore.6.0
Package Description |
|
|
com.ishoperp.EBS.Common.Application
common application |
This package is not used by any popular GitHub repositories.
v2.0.0: Replaced wkhtmltoimage with headless Chromium via PuppeteerSharp. Added async API, macOS support, WebP format, and options pattern.