Generate PDF in ASP.NET Core

Generate PDF

If we write application in version MVC 5 or less. We can use simple to use library like Rotativa. But what if we have apps on ASP.NET MVC Core. Many library is not compatibile with Core yet. I will show you on example how to deal with it.

Example

First, we need to install wkhtmltopdf. Then in our application we’ll need to use WKWrap.Core library.

Above action will return us file pdf with the inscription “Hi”.

Now we can add function that will convert view in the form of a string.

Here is link to example how to write that RenderingViewToString class.

With this way you can generate any pdf from any view.

renderViewToString

Link to project.

Leave a Reply

Your email address will not be published. Required fields are marked *