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
  • 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 2Checkout.com is a worldwide leader in online payment services
  • 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. Add reference to NReco.ImageGenerator.dll assembly OR 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.
Have a question? Feel free to ask.

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)
  • 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 Websites). Also this means that by default non-Windows environments are NOT supported.

  • Both .NET 2.0 and 4.0 runtimes are supported.
  • ImageGenerator works fine with Azure Web Role / Worker Role / usual VM.
  • Mono and .NET Core are supported by special ImageGenerator.LT build that doesn't embed wkhtmltoimage binaries (they should be deployed with your app). These builds are available only for commercial users.
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

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 renders PDF pages to images (web preview, thumbnail etc).