Search code examples
c#.net-corenreco

NReco HtmlToPdfConvertor on .NET Core throws HttpContext exception


When I declare the NReco.PdfGenerator in a .Net Core 2.0 Mvc application I get an error.

  • I added the Nuget package NReco.PdfGenerator 1.1.15 to the project
  • Made a using statement In the controller
  • Declare the HtmlToPdfConverter

[HttpPost]
public IActionResult Index(myModel model)
{
    var html2PdfConverter = new NReco.PdfGenerator.HtmlToPdfConverter();
      
    // etc.   
}

It throws a

Could not load type 'System.Web.HttpContext' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

directly on declaring it.

Has someone had experience with nReco?


Solution

  • I use this in .Net Core and reference the NReco.PdfGenerator.LT nuget package for Html to PDF conversion from NReco.