There are a number of Nuget packages that allow you to create a dynamic PDF document for free in ASP.NET Core.
PDF documents have the benefits of being secure, have a consistent layout and being able to be opened on all major operating systems.
Such uses for PDF documents on a website include sending out invoices to clients or customers.
In addition, they can also be used to capture the layout of a particular website.
In this code example, we go ahead and create an ASP.NET Core MVC application.
We use the Select.HtmlToPdf.NetCore Nuget package to create PDF's for this application.
There is an example of how to capture a particular website in both mobile, tablet and desktop view.
As well as that, there is an example of how to create an invoice in a web application.
Not only can these PDF documents be outputted to the HTTP response, they can also be saved on the server's file storage.
This is the software that will need to be installed onto your machine.
These are the steps to get the application working.
You are now ready to go.
RoundTheCode.Pdf.sln in Visual Studio.
You should find that the web application runs on
Start the project in Visual Studio.
Open up a browser and navigate to
https://localhost:3000/pdf/website. This should generate a PDF document showing RoundTheCode.com layout in mobile, tablet and desktop. It should also save the PDF as
RoundTheCode.pdf in the web directory.
https://localhost:3000/pdf/invoice. This should generate a PDF document of an invoice. It should also save the PDF as
Invoice.pdf in the web directory.
You can read more information by viewing our "How to Create a PDF Document for Free in ASP.NET Core" article.
In-addition, watch our video tutorial, where we go ahead and create PDF documents using HTML and CSS.