ReportProHtmlToPdf 2025.1.2
dotnet add package ReportProHtmlToPdf --version 2025.1.2
NuGet\Install-Package ReportProHtmlToPdf -Version 2025.1.2
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="ReportProHtmlToPdf" Version="2025.1.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ReportProHtmlToPdf" Version="2025.1.2" />
<PackageReference Include="ReportProHtmlToPdf" />
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 ReportProHtmlToPdf --version 2025.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ReportProHtmlToPdf, 2025.1.2"
#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 ReportProHtmlToPdf@2025.1.2
#: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=ReportProHtmlToPdf&version=2025.1.2
#tool nuget:?package=ReportProHtmlToPdf&version=2025.1.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ReportProHtmlToPdf
ReportProHtmlToPdf is a lightweight .NET library that allows you to easily convert Razor views into PDF documents using an HTML-to-PDF rendering engine.
? Features
- Convert Razor Views to PDF files
- Supports ViewModels and dynamic data
- Default A4 paper size with customizable margins
- Footer with automatic page numbering
- UTF-8 encoding support
- Simple API and easy integration
?? Installation
Install the package via NuGet:
dotnet add package ReportProHtmlToPdf --version 2025.1.2
How to Use ReportProHtmlToPdf
Step 1: Add the NuGet package
dotnet add package ReportProHtmlToPdf
Step 2: Register the service in Program.cs
builder.Services.AddReportHtmlToAsPdf();
Step 3: Inject the service in your controller
private readonly IReportProHtmlToPdf _reportProHtmlToPdf;
public ReportsController(IReportProHtmlToPdf reportProHtmlToPdf)
{
_reportProHtmlToPdf = reportProHtmlToPdf;
}
Usage Methods
Method 1: Direct PDF Download
This method generates and downloads the PDF directly without saving it to the server.
var templatePath = "/Views/Employees/_EmployeesReportPDF.cshtml";
var model = await _employeesServicesBL.GetEmployeesForPDF(filterCriteria, User);
var printPdf = await _reportProHtmlToPdf.RenderToPdfAsync(templatePath, model);
return File(printPdf.Pdf, printPdf.ContentType, printPdf.FileName);
templatePath: Razor view path
model: Data model for the view
RenderToPdfAsync: Converts view into PDF in memory
Method 2: Automatic PDF Saving to wwwroot/reportPro
This method automatically saves the PDF file to a folder in wwwroot/reportPro
var printPdf = await _reportProHtmlToPdf.RenderToPdfAsync(
new FilePdfModel
{
ViewPath = templatePath,
FilName = fileName,
Model = data
});
return File(printPdf.Pdf, printPdf.ContentType, printPdf.FileName);
ViewPath: Path to the Razor View
FilName: The name of the generated PDF file
Model: The data model to render the view
The PDF will be saved under
wwwroot/reportPro/{fileName}.pdf
Requirements
.NET 8 or later
MVC/Razor view support
Properly registered service in Program.cs
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- DinkToPdf (>= 1.0.8)
- Microsoft.AspNetCore.Mvc.Razor (>= 2.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.