Printing PDF’s in Blazor

The final result

Exploring the alternatives

PrintJS as baseline

Getting started

Install-Package Append.Blazor.Printing
//using Append.Blazor.Printingbuilder.Services.AddScoped<IPrintingService, PrintingService>();
@using Append.Blazor.Printing
@inject IPrintingService PrintingService
<button @onclick="@(()=> PrintingService.Print("docs/sample.pdf"))">
Print PDF
</button>
public IActionResult Get()
{
var stream = new FileStream(@"path\to\file", FileMode.Open);
return File(stream, "application/pdf", "FileDownloadName.pdf");
}

Caveats

GitHub

Going further

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store