GrapeCity Documents for Imaging (GcImaging) is a high-performance imaging library that can create, load, modify, and save images in .NET Core applications with full support on Windows, macOS, and Linux. GcImaging can be deployed as FaaS with AWS Lambda and Azure functions.

The library is a feature-rich API that can load popular image formats like, BMP, JPEG, TIFF, GIF, and PNG. It can apply advanced image processing techniques and save them back; read/write images, modify images (like rotate, crop, and resize), convert images, apply dithering, and thresholding effects on grayscale images; apply effects on RGB images, draw and fill graphics on images, draw advanced text with full font handling, text, paragraph formatting on images, apply advanced TIFF features, and much more.

Saving web pages directly as HTML may not give the same rendering results as the original HTML, especially when viewing the page on different devices. When browsing the web, some content may need to be used in other formats, (Word, Excel, PowerPoint, or another documents). It's best to have the content as images, so you make edits like re-sizing, formatting or annotating through standard image editors.

Render HTML Content to Images

Watch the video demo:
  1. Create a .NET Core Console application. Include the HTML file in your application.
  2. Add the nuget packages from nuget.org. Choose GrapeCity.Documents.Imaging, GrapeCity.Documents.HTML and the platform specific package -it can be for Windows, Linux or macOS. The current example is demoed on macOS. Let’s choose the package GrapeCity.Documents.Html.Mac.X64.
  3. Add the necessary namespaces.
  4. Create a GcHtmlRenderer object and pass the HTML file to it. This object would render the HTML content on Image.
  5. Create a JPEG setting instance to set the background color and the WindowSize for the image.
  6. Finally, render the html content on the jpeg image and pass the JPEG Settings to the constructor.
  7. Run the application and view the image you just created from HTML file.

Render a text logo to an image

Sometimes, a company’s logo as text needs to be rendered as an image and HTML provides a rich formatting model to do this.

  1. Create a variable to hold the HTML content string.
  2. Create GcHtmlRenderer object and pass the HTML string to its constructor.
  3. Create JPEG setting instance to set the background color and the WindowSize for the image.
  4. Finally, render the html string on the jpeg image and pass the JPEG Settings to the RenderToJpeg constructor.
  5. Run the application and your HTML string of a company logo is added to the image.

Render entire web page to an image

You may also need to render entire web page to an image to annotate the images with certain additions and share with stakeholders. Let’s do this using GcImaging.

  1. Create a uri variable that holds the uri to the webpage.
  2. Create GcHtmlRenderer object and pass the URI string to its constructor.
  3. Create JPEG setting instance to set the background color and the WindowSize for the image.
  4. Finally, render the uri on the jpeg image and pass the JPEG Settings to the RenderToJpeg constructor.
  5. Run the application and your HTML string of a company logo is added to the image.

What do you think about the new features? Leave a comment below.

Try GrapeCity Documents for Imaging free for 30 days

Download the latest version of GrapeCity Documents for Imaging

Download Now!