Skip to footer content

Blazor HTML to PDF using IronPDF

This tutorial guides you through the process of converting HTML to PDF in a Blazor server app using the IronPDF library. Initially, a Blazor server app is created with the IronPDF library installed via the NuGet Package Manager, utilizing the .NET 6 framework. A new Razor component named 'PDFGenerator' is then created, where the page route is defined, and the IJS runtime is injected for downloading files. The tutorial details creating a text area and button, binding the text area to a string variable, and setting up a 'create PDF' function. This function configures the paper size to A2 and employs 'RenderHTMLAsPDF' to convert the HTML string into a PDF. The document is then converted to a stream for downloading. Further steps involve editing the layout.cshtml and navmenu.razor files to facilitate file download and navigation. The tutorial concludes by demonstrating the conversion of an HTML invoice file into a PDF, highlighting the tool's ability to preserve layout and render images effectively. IronPDF is praised for its versatility in editing and converting URLs to PDFs within the .NET framework.

Further Reading: Blazor HTML to PDF using IronPDF

Chipego
Software Engineer
Chipego has a natural skill for listening that helps him to comprehend customer issues, and offer intelligent solutions. He joined the Iron Software team in 2023, after studying a Bachelor of Science in Information Technology. IronPDF and IronOCR are the two products Chipego has been focusing on, but his knowledge of all products is growing daily, as he finds new ways to support customers. He enjoys how collaborative life is at Iron Software, with team members from across the company bringing their varied experience to contribute to effective, innovative solutions. When Chipego is away from his desk, he can often be found enjoying a good book or playing football.