# HtmlRendererCore: HTML to PDF Rendering for .NET Core

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/j-petty-htmlrenderercore
Generated for open source discovery and AI-assisted research.

HtmlRendererCore is a partial port of the popular HtmlRenderer library, specifically designed to bring robust HTML to PDF conversion capabilities to .NET Core projects. It leverages PdfSharpCore to enable developers to easily generate PDF documents from HTML content, making it a valuable tool for various application needs.

GitHub: https://github.com/j-petty/HtmlRendererCore
OSRepos URL: https://osrepos.com/repo/j-petty-htmlrenderercore

## Summary

HtmlRendererCore is a partial port of the popular HtmlRenderer library, specifically designed to bring robust HTML to PDF conversion capabilities to .NET Core projects. It leverages PdfSharpCore to enable developers to easily generate PDF documents from HTML content, making it a valuable tool for various application needs.

## Topics

- C#
- .NET Core
- HTML to PDF
- PDF Generation
- Open Source
- Library
- PdfSharpCore
- Rendering

## Repository Information

Last analyzed by OSRepos: Sun Oct 12 2025 09:31:04 GMT+0100 (Western European Summer Time)
Detail views: 8
GitHub clicks: 8

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

HtmlRendererCore is an essential library for .NET Core developers needing to convert HTML content into PDF documents. As a partial port of the well-known HtmlRenderer, it extends its powerful rendering capabilities to the modern .NET Core ecosystem. This project integrates seamlessly with PdfSharpCore, providing a straightforward solution for generating high-quality PDFs directly from HTML strings.

## Installation

HtmlRendererCore is available as a NuGet package, making it easy to integrate into your .NET Core projects. You can add it using the NuGet Package Manager or via the .NET CLI:

bash
dotnet add package HtmlRendererCore.PdfSharp


This package includes the necessary components for HTML to PDF conversion using PdfSharpCore.

## Examples

The library provides simple and intuitive methods for generating PDFs. Here are a couple of common use cases:

### Generate PDF from HTML

To convert an HTML string into a PDF document, you can use the `PdfGenerator` class:

cs
var pdf = PdfGenerator.GeneratePdf(html, PdfSharpCore.PageSize.A4);
// 'pdf' is now a PdfDocument object that can be saved or manipulated.


### Generating Base64 PDF from HTML

For scenarios where you need the PDF content as a Base64 encoded string, such as for API responses or embedding, you can do the following:

cs
var result = string.Empty;

using (var stream = new MemoryStream())
{
    var pdf = PdfGenerator.GeneratePdf(html, PdfSharpCore.PageSize.A4);

    pdf.Save(stream);

    result = Convert.ToBase64String(stream.ToArray());
}
// 'result' now contains the Base64 encoded PDF string.


## Why Use It?

HtmlRendererCore fills a crucial gap for .NET Core developers by offering a reliable and efficient way to convert HTML to PDF. Its benefits include:

*   **.NET Core Compatibility**: Specifically designed for the modern .NET Core framework.
*   **Ease of Use**: Simple API for quick integration and PDF generation.
*   **Leverages PdfSharpCore**: Builds upon a robust and widely used PDF library.
*   **Open Source**: Actively maintained and open to community contributions, ensuring flexibility and transparency.
*   **Versatile**: Suitable for various applications, from generating reports and invoices to dynamic content archiving.

## Links

*   **GitHub Repository**: [j-petty/HtmlRendererCore](https://github.com/j-petty/HtmlRendererCore)
*   **Original HtmlRenderer**: [HtmlRenderer (Codeplex Archive)](https://archive.codeplex.com/?p=htmlrenderer)
*   **PdfSharpCore**: [ststeiger/PdfSharpCore](https://github.com/ststeiger/PdfSharpCore)