
So you can use models, viewbags, tempdata, and all stuff like that. Or you can go even further and prepare a whole service that will use Razor Pages to generate raw HTML out of.

First, you can prepare HTML templates, and just ‘replace’ some values.

Yeah, and right now I’m about to tell you how to do it with an ASP.NET Core application!īasically, there are two ways. You have mentioned that we can generate PDFs out of HTML templates! Puppeteer Sharp has great documentation along with great support.ĭon’t be afraid to check it out: Github Repository After running it, this is what we’ve got: Return File(pdfContent, "application/pdf", "converted.pdf") Var pdfContent = await page.PdfStreamAsync(new PdfOptions Here is an ASP.NET Core Web API Action Example ASP.NET Core Web API Action Example Īwait new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision) Īwait using var browser = await Puppeteer.LaunchAsync(new LaunchOptionsĪwait using var page = await browser.NewPageAsync() Īwait page.EmulateMediaTypeAsync(MediaType.Screen) Īwait page.SetContentAsync("Hello PDF world!Greetings from HTML world") Contact usįirst, we have to install the Puppeteer Sharp Nuget Package in our project.Īfter doing that, within a few lines of code, we can convert our HTML to PDF. Let’s talk and discuss how we can help you. Want specialists to implement the solution for you? The Puppeteer comes from the NodeJS world, and the Puppeteer Sharp is a port to. Wait what… haven’t I seen this in the Javascript world? Let me introduce you to the Puppeteer Sharp. This is the moment you have been waiting for. You would like to create the PDF, but most of the libraries are paid, and they cost A LOT.Īlso, when you manage to find a free version or open-source version of a library, it is not supported anymore, or it does not work the way you expect. The Problem: Generating PDF From HTML in. NET Core applications is not straightforward. The most convenient way to do it would be to create HTML templates and then convert them into PDF. It can be a small or enterprise application: at some point, you will benefit from generating PDF files. No matter what kind of application you are creating. Want specialists to implement the solution for you?.

The Problem: Generating PDF From HTML in.
