WhuPdfGenerator 1.0.4
dotnet add package WhuPdfGenerator --version 1.0.4
NuGet\Install-Package WhuPdfGenerator -Version 1.0.4
<PackageReference Include="WhuPdfGenerator" Version="1.0.4" />
<PackageVersion Include="WhuPdfGenerator" Version="1.0.4" />
<PackageReference Include="WhuPdfGenerator" />
paket add WhuPdfGenerator --version 1.0.4
#r "nuget: WhuPdfGenerator, 1.0.4"
#:package WhuPdfGenerator@1.0.4
#addin nuget:?package=WhuPdfGenerator&version=1.0.4
#tool nuget:?package=WhuPdfGenerator&version=1.0.4
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 | Versions 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. |
-
net8.0
- AngleSharp (>= 1.1.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.