Milan Jovanović Creates PDF Documents in ASP .NET Core - And IronPDF Is His Library of Choice

Milan, a software architect, Microsoft MVP, and one of the most respected voices in the .NET ecosystem,published a deep dive into PDF generation in .NET Core. He walked through multiple real-world patterns including dynamic document creation, PDF merging, and serving files from API endpoints.
His library of choice for all of it? IronPDF. In his own words: "IronPDF is the library I've used most often on commercial projects.”
Let's walk through exactly how he uses it.
The Approach: HTML Templates With Razor Views
The more common approach for generating PDF files is using an HTML template.
It’s the combination of ASP.NET Core MVC Razor views with IronPDF's rendering engine. By using strongly typed views, he can pass C# objects directly into the template at runtime to generate dynamic, data-driven documents.
Here's the pattern in action. First, a Razor view defines the document layout:
@model ViewModels.InoviceViewModel
<div>Invoice number: @Model.InvoiceNumber</div>
<div>Invoice date: @Model.InvoiceDate</div>
<br/>
<span>Line items:</span>
<ul>
@foreach(var lineItem in Model.LineItems)
{
<li>@lineItem.Name | @lineItem.Price</li>
}
</ul>
@model ViewModels.InoviceViewModel
<div>Invoice number: @Model.InvoiceNumber</div>
<div>Invoice date: @Model.InvoiceDate</div>
<br/>
<span>Line items:</span>
<ul>
@foreach(var lineItem in Model.LineItems)
{
<li>@lineItem.Name | @lineItem.Price</li>
}
</ul>@ModelType ViewModels.InoviceViewModel
<div>Invoice number: @Model.InvoiceNumber</div>
<div>Invoice date: @Model.InvoiceDate</div>
<br/>
<span>Line items:</span>
<ul>
@For Each lineItem In Model.LineItems
<li>@lineItem.Name | @lineItem.Price</li>
Next
</ul>Then, IronPDF's ChromePdfRenderer converts that rendered HTML into a polished PDF:
var html = ConvertRazorViewToHtml(invoice);
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs($"invoice-{invoice.InvoiceNumber}.pdf");var html = ConvertRazorViewToHtml(invoice);
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs($"invoice-{invoice.InvoiceNumber}.pdf");Dim html = ConvertRazorViewToHtml(invoice)
Dim renderer = New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs($"invoice-{invoice.InvoiceNumber}.pdf")Three lines of C# code. The Razor view handles all the layout logic, CSS handles the styling, and IronPDF handles the conversion. As Milan notes, "It really is that simple."
Why Milan Chooses This Over Alternatives
Milan has worked with PDF libraries across multiple commercial projects, and his preference for IronPDF comes down to a few key factors he highlights in his article.
The Chromium rendering engine delivers consistent results. IronPDF renders HTML using the same engine that powers Chrome, which means your PDF output matches exactly what you'd see in a browser.
CSS gives you complete control over formatting. Instead of learning a proprietary layout API, you use the same CSS you'd write for any web page. Flexbox, grid, custom fonts, responsive spacing, it all translates directly to the PDF output.
Real-World Pattern: Merging Multiple PDFs
Milan walks through a common business requirement, combining multiple PDF files into a single document. Think monthly receipts that need to be bundled for accounting, or report sections that need to be assembled into a final deliverable.
Real-World Pattern: Serving PDFs From an API
Milan also shows how naturally IronPDF fits into ASP.NET Core's Minimal API pattern. Returning a dynamically generated PDF from an endpoint.
Read Milan's Full Article
Milan's complete breakdown covers additional implementation details and code samples that are worth exploring if you're evaluating PDF generation approaches for your .NET projects.
Try It Yourself
IronPDF is free for development use, so you can test Milan's patterns in your own projects without any commitment. Install via NuGet: