HTML to Image Generator for .NET C# WkHtmlToImage Wrapper


features

  • Render HTML pages (with floating divs, CSS, images, javascript code) to image (jpg,png) canvas with WebKit engine (based on WkHtmlToImage tool)
  • Convert HTML to image (jpg,png) from any .NET application (including ASP.NET WebForms, MVC)
  • Generate web page thumbnail (web page screenshot)
  • Render SVG to PNG/Jpeg (charts, diagrams) on the server side
  • Easy to use WkHtmlToImage C# wrapper library: all you need is one assembly.
    In case of .NET Core wkhtmltoimage should be deployed separately.
  • Usage examples (C#):
    • WebForms: web page preview (take a screenshot of a web page)
    • MVC.NET samples:
      • export GoogleChart SVG to image
      • generate Barcode image from HTML+Javascript
  • Looking for HTML to PDF converter? Try NReco.PdfGenerator

download and pricing

quick purchase process

  • 1 Choose a package
  • 2 Pay online Online payment methods
  • 3 Download the package
Need to perform HTML to image conversion from C# code and get similar to web browser rendering result? NReco.ImageGenerator is a right choice!

how to use

  1. Install NReco.ImageGenerator nuget package
  2. Render HTML to image with one line of C# code:
    var html = String.Format("<body>Hello world: {0}</body>",DateTime.Now);
    var htmlToImageConv = new NReco.ImageGenerator.HtmlToImageConverter();
    var jpegBytes = htmlToImageConv.GenerateImage(html, ImageFormat.Jpeg);
  3. That's all! Check out online documentation for additional options.
Feel free to contact us in case of any questions.

render HTML to image demo

Web page URL:
Notice: don't use intranet/extranet/VPN/local URLs (like 'localhost').
In most cases they are not accessible by our server and require authentication; ImageGenerator will able to convert these pages only when hosted on your server.
Get Web Page Thumbnail (Preview)

frequently asked questions

ImageGenerator can be used for FREE in single-deployment projects (websites, intranet/extranet) or applications for company's internal business purposes (redistributed only internally inside the company).

Commercial license is required for:
  • Applications for external redistribution (ISV) or multiple deployments
  • SaaS deployments
Note that support is NOT available for free users.
It is possible to include images by specifying their FULL URL or path (if they're on local filesystem). External CSS and javascript files are also supported.
ImageGenerator embeds WkHtmlToImage x86 binaries and invokes it in separate process with System.Diagnostics.Process. In case of ASP.NET applications this might be prohibited in partial trust environments (shared ASP.NET hostings, Azure Apps shared). Also this means that non-Windows environments are NOT supported by NReco.ImageGenerator nuget package.

  • Minimal .NET Framework version is 4.5 (or higher).
  • ImageGenerator works fine with Azure VM instances / ServiceFabric. Azure Apps (shared plans) are not supported.
  • .NET Core and Mono are supported by special ImageGenerator.LT build that doesn't include wkhtmltoimage binaries (they should be deployed/installed separately). LT build is available only for commercial users (requires a license key).
In some cases image generation fails with one of the following errors:
  • Exit with code 1 due to network error: ContentNotFoundError
  • Exit with code 1 due to network error: ProtocolUnknownError
  • Exit with code 1 due to network error: HostNotFoundError
This means that HTML template has external reference (js/css/image URL) that cannot be loaded by WkHtmlToImage. In most cases image can be generated anyway by specifying additional WkHtmlToImage parameter:
var htmlToImage = new HtmlToImageConverter();
htmlToImage.CustomArgs = " --load-media-error-handling ignore ";

what's new

2020 Jun 15 v.1.2.0 changes:
  • wkhtmltoimage upgraded to 0.12.6 (released on 2020-Jun-11)
2019 Apr 03 v.1.1.3 changes:
  • fixed issue with exceptions inside AsyncStreamCopyTo
  • net20 target is not supported any more, minimal legacy target is net45
2018 Nov 23 v.1.1.2 changes:
  • added netstandard20 build (update affects only NReco.ImageGenerator.LT nuget package)
2017 Nov 23 v.1.1.1 changes:
  • fixed issue with ExecutionTimeout (didn't work)
  • added LogReceived event
2017 Mar 31 v.1.1.0 changes:
  • WkHtmlToImage tool upgraded to version 0.12.4 (released 2016-Nov-22)
  • all necessary VC++ Runtime 2015 dlls are included
  • now for ASP.NET apps wkhtmltoimage binaries are extracted to 'App_Data\wkhtmltoimage' by default
2015 Sep 10 v.1.0.3 changes:
  • hotfix for '(0) is invalid for Enum type 'ProcessPriorityClass' error
  • VC++ 2013 runtime libs (msvcp120.dll, msvcr120.dll) required by wkhtmltoimage.exe are included as embedded resources (no need to install VC++ 2013 redist)
2015 Aug 27 v.1.0.2 changes:
  • added ProcessPriority and ExecutionTimeout properties
  • added workaround for "Exit with code 1 due to network error" wkhtmltoimage issue: when "--load-error-handling" or "--load-media-error-handling" set to "ignore" (or "skip") wkhtmltoimage generates an image but exited with code = 1 and as result WkHtmlToImageException is thrown. Now this case is handled correctly and exception is not thrown.
  • now NReco.ImageGenerator.dll is a signed (strongly named) assembly
2015 Feb 02 v.1.0.1: Fixed issue with image format (was ignored)
2015 Jan 24 v.1.0: Initial ImageGenerator release based on WkHtmlToImage v.0.12.2.1

more components

  • HTML-to-PDF Generator

    .NET wrapper for WkHtmlToPdf utility that generates PDF reports by HTML template.

  • PDF-to-Image Renderer

    .NET wrapper for poppler tools that converts PDF pages to images or text (ASP.NET PDF viewer, PDF thumbnails, extract PDF text/images).