SimpleHtmlToPdf 3.0.0

dotnet add package SimpleHtmlToPdf --version 3.0.0                
NuGet\Install-Package SimpleHtmlToPdf -Version 3.0.0                
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="SimpleHtmlToPdf" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleHtmlToPdf --version 3.0.0                
#r "nuget: SimpleHtmlToPdf, 3.0.0"                
#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.
// Install SimpleHtmlToPdf as a Cake Addin
#addin nuget:?package=SimpleHtmlToPdf&version=3.0.0

// Install SimpleHtmlToPdf as a Cake Tool
#tool nuget:?package=SimpleHtmlToPdf&version=3.0.0                

Simple HTML to PDF

.NET Publish

Simple HTML to PDF is a lightweight NuGet package that provides a simple HTML to PDF converter library for .NET projects. It allows you to easily convert HTML content to PDF documents using the wkhtmltopdf command-line tool.

Installation

You can install the Simple HTML to PDF package via NuGet Package Manager or by using the .NET CLI.

NuGet Package Manager

  1. Open the NuGet Package Manager in Visual Studio.

  2. Search for "SimpleHtmlToPdf" and select the package.

  3. Click on the "Install" button to install the package into your project.

.NET CLI

Execute the following command in the terminal:

dotnet add package SimpleHtmlToPdf

Usage

To use the Simple HTML to PDF library in your project, follow these steps:

  1. Install the Simple HTML to PDF package (as described in the Installation section).

  2. Add it to your project's IoC container:

    services.AddSimpleHtmlToPdf();
    

Replace services with the actual IServiceCollection instance in your project.

  1. Ask for an instance of the IConverter class from the system's IoC:

    public HomeController(IConverter converter) { ... }
    
  2. Convert an HTML string to a PDF document:

     // Define the HTML-to-PDF request input
     var doc = new HtmlToPdfDocument()
     {
         GlobalSettings = {
             // Color mode of the output file
             ColorMode = ColorMode.Color,
             // Orientation of the output file
             Orientation = Orientation.Landscape,
             // Paper size of the output file
             PaperSize = PaperKind.A4Plus,
         },
         Objects = {
             new ObjectSettings()
             {
                 // HTML content to convert
                 HtmlContent = "<html><body>Test</body></html>",
                 // The default encoding used.
                 WebSettings = { DefaultEncoding = "utf-8" },
             },
         }
     };
    
     // Convert our HTML document to a PDF document
     var pdf = Converter.Convert(doc);
    

    Replace HtmlContent with the actual HTML content you want to convert.

  3. Send the PDF file to the browser:

    return File(pdf, "application/pdf", "Test.pdf");
    

    Customize based on your requirements.

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  1. Fork the repository.

  2. Create a new branch:

    git checkout -b feature/your-feature-name
    
  3. Make your changes and commit them:

    git commit -m "Add your commit message"
    
  4. Push your changes to your forked repository:

    git push origin feature/your-feature-name
    
  5. Open a pull request in this repository, and provide a detailed description of your changes.

License

This project is licensed under the Apache 2 License.

Acknowledgments

  • The wkhtmltopdf tool, which enables HTML to PDF conversion.
  • The DinkToPDF library, which provided the initial code.
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 is compatible. 
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
3.0.0 290 11/25/2024
2.1.15 484 11/12/2024
2.1.14 263 11/11/2024
2.1.13 1,200 11/5/2024
2.1.12 214 11/4/2024
2.1.11 292 10/29/2024
2.1.10 193 10/29/2024
2.1.9 577 10/15/2024
2.1.8 291 10/10/2024
2.1.7 770 8/23/2024
2.1.6 390 8/14/2024
2.1.5 222 8/2/2024
2.1.4 1,281 6/25/2024
2.1.3 797 6/18/2024
2.1.2 456 6/17/2024
2.1.1 458 5/13/2024
2.1.0 307 5/13/2024
2.0.48 227 5/13/2024
2.0.47 367 5/7/2024
2.0.46 291 5/6/2024
2.0.45 294 5/2/2024
2.0.44 314 5/1/2024
2.0.43 329 4/30/2024
2.0.42 491 3/28/2024
2.0.41 448 3/15/2024
2.0.40 421 3/14/2024
2.0.39 882 3/5/2024
2.0.38 366 3/4/2024
2.0.37 325 2/27/2024
2.0.36 362 2/22/2024
2.0.35 307 2/19/2024
2.0.34 249 2/5/2024
2.0.33 216 1/30/2024
2.0.32 218 1/22/2024
2.0.31 501 12/18/2023
2.0.30 394 12/12/2023
2.0.29 376 12/11/2023
2.0.28 471 11/20/2023
2.0.27 1,229 11/17/2023
2.0.26 372 11/16/2023
2.0.25 256 11/7/2023
2.0.24 836 11/6/2023
2.0.23 449 10/31/2023
2.0.22 435 10/30/2023
2.0.21 600 9/20/2023
2.0.20 437 9/19/2023
2.0.19 444 9/18/2023
2.0.18 732 9/12/2023
2.0.17 664 9/6/2023
2.0.16 462 9/5/2023
2.0.15 502 9/4/2023
2.0.14 521 9/1/2023
2.0.13 487 8/31/2023
2.0.12 512 8/30/2023
2.0.11 521 8/29/2023
2.0.10 848 8/9/2023
2.0.9 627 8/8/2023
2.0.8 860 7/13/2023
2.0.7 473 7/13/2023
2.0.6 432 7/11/2023
2.0.5 399 7/8/2023
2.0.4 502 7/8/2023
2.0.3 477 7/8/2023
2.0.2 535 7/8/2023
2.0.1 486 7/8/2023
2.0.0 1,055 12/12/2022
1.0.18 772 10/11/2022
1.0.17 1,191 6/10/2022
1.0.13 1,079 1/11/2022
1.0.11 756 2/24/2021
1.0.10 696 1/7/2021
1.0.7 762 10/30/2020
1.0.6 925 9/13/2020
1.0.5 834 5/4/2020
1.0.4 800 5/4/2020
1.0.3 774 5/4/2020
1.0.2 961 5/4/2020