You can use jsreport .net sdk if you are in .net core 2.0 also without more complex node services. This includes among other features filters to convert your existing razor views into pdf. From the docs:
1.
Install nugets jsreport.Binary, jsreport.Local and jsreport.AspNetCore
2.
In you Startup.cs
configure it as the following
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddJsReport(new LocalReporting()
.UseBinary(JsReportBinary.GetBinary())
.AsUtility()
.Create());
}
3.
Then you need to add MiddlewareFilter
attribute to the particular action and specify which conversion you want to use. In this case html to pdf conversion.
[MiddlewareFilter(typeof(JsReportPipeline))]
public IActionResult Invoice()
{
HttpContext.JsReportFeature().Recipe(Recipe.ChromePdf);
return View();
}
You can reach bunch of other options for headers, footers or page layout on JsReportFeature()
. Note that the same way you can also produce excel files from html. See more information in the documentation.
PS: I'm the author of jsreport.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…