j-petty

HtmlRendererCore: Convert HTML to PDF in .NET Core

HtmlRendererCore is a partial port of HtmlRenderer for .NET Core projects. It converts HTML into PDF documents using PdfSharpCore, making it useful when an application needs basic HTML-to-PDF generation in C#.

Stars
34
Forks
10
Stars, last 16 days
+0

Our take

Health score

17/100

How it is scored
Activity
20
Community
4
Issues
21
Pull requests
21

+0 stars in the last 16 days

  • Fewer contributors than 91% of the projects we track

Overview

HtmlRendererCore brings HTML-to-PDF generation to .NET Core applications by combining a partial port of HtmlRenderer with PdfSharpCore. It is aimed at developers who need to create PDF documents from HTML within a C# project rather than use a separate conversion service.

The project is a fit for straightforward PDF generation, but it does not claim complete HTML-rendering coverage. Its maintainers describe broader rendering support as future work.

Key Features

  • Generates PDF documents from HTML strings.
  • Uses PdfSharpCore to create PDFs.
  • Supports specifying a page size, such as A4.
  • Allows generated PDFs to be saved to a stream and encoded as Base64.
  • Provides a .NET Core-oriented partial port of HtmlRenderer.

Use Cases

  • A .NET Core developer needs to generate a basic PDF from HTML in an application.
  • A service needs to return a generated PDF as a file or stream.
  • An application needs to encode a generated PDF as Base64 for transfer or storage.

Getting Started

Use PdfGenerator.GeneratePdf with the HTML content and a page size:

var pdf = PdfGenerator.GeneratePdf(html, PdfSharpCore.PageSize.A4);

See the repository README for additional usage details. The project uses PdfSharpCore.

Alternatives

  • QuestPDF: QuestPDF builds PDFs with a fluent component API rather than converting HTML, so it suits structured documents instead of HTML-based layouts.
ProjectLanguageLicenseStarsStatus
HtmlRendererCoreC#MIT34Not checked yet
QuestPDFC#–14.2kActive

Considerations

  • This is a partial port, so it may not support all HTML-rendering behavior available in the original HtmlRenderer.
  • The README identifies support for more advanced HTML rendering as future work.
  • PDF generation depends on PdfSharpCore; check its documentation and compatibility for your project before adopting this library.

Found this useful?

Share it with someone who would like HtmlRendererCore.

Comparisons