Build a Simple Invoice App & Print Invoices with .NET MAUI

Fox Learn Guide 8 months ago

Description

Build a Simple Invoice App & Print RDLC Report with .NET MAUI
In the previous part, we designed the layout in MainPage.xaml, created data models like Order and OrderDetail, and used INotifyPropertyChanged to update the UI automatically.

In this part, we’ll continue by implementing printing functionality for our .NET MAUI Invoice App.

You’ll learn how to generate an RDLC report on the server, return it as a PDF, and open it directly from your .NET MAUI app, step by step.

We’ll walk through:

Adding a new HTTP POST API action in ReportController to generate and return the PDF.

Creating an IInvoiceService and implementing it with InvoiceService in .NET MAUI.

Using HttpClient to call the Web API, save the PDF locally, and open it with the platform viewer.

Injecting the service into your MAUI page and wiring up the PrintInvoice_Clicked event handler.

Registering the service in MauiProgram.cs and configuring the HttpClient.

Running and testing the feature on both Windows and the Android emulator.

By the end of this tutorial, you’ll be able to save an invoice, generate it as a PDF, and open it seamlessly on both Windows and Android devices.