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.
If you want to save desktop web pages (or if you try to print directly) you may experience the following issues:
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.
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:
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.
Getting started with HTML to PDF conversion
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.