WhuPdfGenerator 1.0.4

dotnet add package WhuPdfGenerator --version 1.0.4
                    
NuGet\Install-Package WhuPdfGenerator -Version 1.0.4
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WhuPdfGenerator" Version="1.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WhuPdfGenerator" Version="1.0.4" />
                    
Directory.Packages.props
<PackageReference Include="WhuPdfGenerator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WhuPdfGenerator --version 1.0.4
                    
#r "nuget: WhuPdfGenerator, 1.0.4"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WhuPdfGenerator@1.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WhuPdfGenerator&version=1.0.4
                    
Install as a Cake Addin
#tool nuget:?package=WhuPdfGenerator&version=1.0.4
                    
Install as a Cake Tool

WhuPdfGenerator

WhuPdfGenerator is a .NET library designed for generating PDF files from HTML content. It converts an HTML string into a PDF file represented as a byte array, which can be easily saved, sent, or displayed.

Features

  • Simple and fast HTML-to-PDF conversion
  • Outputs PDF as a byte array for flexible usage
  • Ideal for dynamic content generation such as invoices, reports, and more

Installation

Install WhuPdfGenerator via NuGet Package Manager:

dotnet add package WhuPdfGenerator

Or install directly from the NuGet Package Manager UI in Visual Studio.

Usage

To use WhuPdfGenerator, include the library in your project and pass your HTML string to the generator to produce a PDF as a byte array.

Example
using PdfGenerator.Infrastructure;

// Sample HTML content
string htmlContent = """
    <html>
        <body>
            <h1>Hello, World!</h1>
            <p>This is a sample PDF document generated from HTML.</p>
        </body>
    </html>
    """;

// Generate PDF as byte array
var pdfService = new PdfService();
var pdfBytes = await pdfService.GenerateAsync(htmlContent, 300);

// Save the PDF to a file
string filePath = "output.pdf";
System.IO.File.WriteAllBytes(filePath, pdfBytes);

Console.WriteLine($"PDF generated successfully and saved to {filePath}");

Method

Task<byte[]> GenerateAsync(string htmlContent, int dpi = 180, CancellationToken cancellationToken = default)

Accepts an HTML string as input and returns a PDF document as a byte array.

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.4 222 11/1/2024
1.0.3 188 11/1/2024