We are pleased to announce the release of GrapeCity Documents for PDF (GcPdf) v3. With this release, GcPdf adds additional features to program PDF documents in .NET Core applications. The main highlight of this release is the ability to convert HTML content to PDF.

Rendering HTML Content to a PDF

Render HTML Content to PDF

If you want to save desktop web pages (or if you try to print directly) you may experience the following issues:

  • CSS styles responsible for displaying pages effectively on any device may not render well
  • Background images are sometimes lost
  • Layout and flow of pages may not be the same upon printing

Why Convert HTML to PDF?

Example: An eCommerce site presents a customer invoice on the web page shopping cart and then prints the invoice to include with the order. As mentioned above, there may be issues when printing HTML content directly to a printer, or sharing the HTML with customers. The formatting may not be preserved, and the layout and styles may not be supported, if the HTML invoice is viewed offline.

A PDF format is a preferred choice for viewing and document sharing. PDF formats are the most reliable document format to view web content offline, since the document format is preserved regardless of platform or device. The invoice HTML conversion needs an automated process, as several invoices are generated through the day.

Developing such applications would benefit from an API that can convert the HTML content to a PDF.

GrapeCity Documents for HTML

You can now convert HTML content to PDF using the new GrapeCity Documents for HTML (GcHtml) package (a utility package for GcPdf and GcImaging) available with the GcPdf/GcImaging packages. It is a platform independent package that allows you to convert HTML content to PDF documents or images (PNG or JPEG).

It provides a set of extension methods DrawHtml() and MeasureHtml() to draw or measure HTML content on an instance of GcPdfGraphics. This helps to insert HTML fragments into PDF documents along with other content. HTML rendering is done using the industry standard Chrome web browser engine working in headless mode, offering advantages of rendering HTML to PDF on any platform (Windows, Linux, and macOS). Users can additionally set various PDF settings while converting HTML to PDF. There is no additional license required to run GcHtml.

The package: GrapeCity.Documents.Html includes the GcHtmlRenderer class, the main class that can render HTML content in PDF Pages.

Internally, it uses one of 3 system-dependent HTML engine packages:

  • GrapeCity.Documents.Html.Windows.X64
  • GrapeCity.Documents.Html.Mac.X64
  • GrapeCity.Documents.Html.Linux.X64

GcHtml will automatically select the correct system-dependent engine package at runtime, but that package must be referenced by your project so that GcHtml can find it. You can add references to all three platform packages to your project, or only target one or two platforms, just add the relevant packages for the target platforms.

Key Features

  • Multi-platform package to render HTML content on Windows, macOS or Linux
  • Renders HTML content from a page/URI source or HTML string to PDF
  • Supports:
    • Images
    • Hyperlinks
    • CSS
    • JavaScript
    • HTML5
    • Page breaks
    • SVG
    • HTML tables
  • Supports PDF settings:
    • Default background
    • No background
    • Page height
    • Page width
    • IgnoreCSSPageSize
    • Landscape
    • Scale
    • Page ranges to specify which pages should be rendered in the output PDF file
    • DisplayHeaderFooter
    • Define Header/Footer templates
  • Split long HTML content into multiple pages
  • Specify page margins

Getting started with HTML to PDF conversion

Also visit:

Help | GcHtml Architecture | Demo

Import Form Data Submitted from the Client to PDF

GcPdf adds new GcPdfDocument.ImportFormDataFromCollection() method. This method makes it easy to take field names/value lists sent by a form submit and imports it into similarly structured PDF Forms. Almost no code is needed to manipulate that data.

Visit our Demo for more details.

Get GrapeCity Documents for PDF free for 30 days

Download the latest version of GrapeCity Documents for PDF

Download Now!