Skip to content

Eric898989/net-core-html-to-image

 
 

Repository files navigation

Build Status NuGet

.NET Core HTML to Image converter

This is a .NET Core HTML to Image converter. It helps converting HTML strings or URLs to image bytes. Please see the examples:

Installation

Nuget package available (https://www.nuget.org/packages/CoreHtmlToImage/)

Install-Package CoreHtmlToImage

Convert HTML string to image bytes

var converter = new HtmlConverter();
var html = "<div><strong>Hello</strong> World!</div>";
var bytes = converter.FromHtmlString(html);
File.WriteAllBytes("image.jpg", bytes);

Convert URL to image bytes

var converter = new HtmlConverter();
var bytes = converter.FromUrl("http://google.com");
File.WriteAllBytes("image.jpg", bytes);

Optional parameters

  1. width - output document width. Default is 1024.
  2. format - output image format. Default is Jpg.
  3. quality - output image quality from 1 to 100. Default is 100.

Roadmap

  • Async interface

More about this library

Because I couldn't find a free implementation of .NET Core HTML to Image library, I've developed my own and hope it will help other people as well. This library wraps very nice wkhtmltoimage tool (https://wkhtmltopdf.org/). I have wkhtmltoimage.exe embedded into my library. This is a very simple implementation. Your contributions are very welcome!

About

.NET Core HTML to Image converter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%