---
title: "Add PDF functionality on Android using .NET | Nutrient .NET Mobile SDK for Android"
canonical_url: "https://www.nutrient.io/sdk/dotnet-for-android/getting-started/"
md_url: "https://www.nutrient.io/sdk/dotnet-for-android/getting-started.md"
last_updated: "2026-05-30T02:20:01.489Z"
description: "Learn how to integrate Nutrient .NET for Android SDK into your .NET project. Step-by-step guide for adding PDF viewing, editing, and annotation features."
---

# Add PDF functionality on Android using .NET

This guide explains how to integrate Nutrient.NET Mobile SDK for Android into a new or existing.NET project. By the end, you’ll be able to display a PDF document using the default Nutrient user interface (UI).

**Jump to Android specific example**

View the example repo on GitHub.

[Read more](https://github.com/PSPDFKit/dotnet-pdf-library-for-android.git)

**Jump to example supporting iOS and Android**

View the example repo on GitHub.

[Read more](https://github.com/PSPDFKit/dotnet-pdf-library-for-mobiles.git)

## Requirements

- [Latest stable version of Visual Studio](https://visualstudio.microsoft.com)

- [Latest stable version of the.NET SDK](https://dotnet.microsoft.com/en-us/download)

- [Latest stable version of the `android` workload](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install)

- [Latest stable version of Microsoft Build of OpenJDK](https://learn.microsoft.com/en-us/java/openjdk/download)

- [Latest stable version of Android Studio](https://developer.android.com/studio)

- The [Android Native Development Kit (NDK)](https://developer.android.com/studio/projects/install-ndk)

- An [Android Virtual Device](https://developer.android.com/studio/run/managing-avds.html) or hardware device

## Creating a new project

If you already have an existing.NET for Android or MAUI project that runs on Android using the latest version of the `android` or `maui` workloads, jump to the [Adding Nutrient to your project](#adding-nutrient-to-your-project) section.

**Steps:**

1. Use the dotnet [CLI](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-new) to create a new Android solution:

   ```bash

   dotnet new android -n Nutrient-Demo
   ```

   You can use `dotnet new android -h` to learn more about the dotnet new android command.

2. Navigate to your newly created.NET `Android` project directory, `Nutrient-Demo`:

   ```sh

   cd./Nutrient-Demo
   ```

## Adding Nutrient to your project

### Using.NET CLI

Use the dotnet [CLI](https://learn.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-using-the-dotnet-cli) to add the Nutrient NuGet packages to your solution.

```bash

dotnet add package Nutrient.dotnet.Android

```

You can use `dotnet add package -h` to learn more about the dotnet add package command.

### Using Visual Studio

**Steps:**

1. Open your solution in Visual Studio.

   ```bash

   open path/to/YourSolution.sln
   ```

2. Right-click your solution in Visual Studio and select the **Manage NuGet Packages…**.

3. In the **Browse** section of nuget.org, search for `Nutrient.dotnet`.

4. Select the `Nutrient.dotnet.Android` package.

5. Tap the **Add Packages** button to add the NuGet packages to your solution.

## Displaying document in your app

**Steps:**

1. Open your solution/csproj in Visual Studio if not already open.

   ```bash

   open path/to/YourSolution.sln
   ```

2. Open the `AndroidManifest.xml` file.

3. Edit the file to add the `PdfActivity` to the `<application>` tag.

   ```xml

   <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme">
     <activity android:name="com.pspdfkit.ui.PdfActivity"/>...
   </application>
   ```

4. Add the PDF document you want to display to your application by dragging it into your solution’s assets. You can download our [sample PDF](https://www.nutrient.io/assets/nutrient-media/files/document.pdf) as an example. If you don’t have an Assets folder, create one.

5. Import the following namespaces at the top of your `MainActivity.cs` file:

   ```csharp

   using PSPDFKit.UI;  // To display the PDF.
   using PSPDFKit.Configuration.Activity;  // For `PdfActivityConfiguration`.
   using PSPDFKit.Configuration.Page;  // For activity configuration properties.
   using Android.Content.Res;  // For Assets access.
   using System.IO;  // Path creation.
   using Java.IO;  // File creation.
   ```

6. Make sure to call `NutrientGlobal.Initialize` with your license key to initialize Nutrient and add it to the `OnCreate` method in the generated `MainActivity.cs` code.

   ```csharp <!-- Lines inserted: [5, 6] -->

   protected override void OnCreate(Bundle savedInstanceState)
   {
     base.OnCreate(savedInstanceState);

      // Set your `licenseKey` here and initialize Nutrient.
      // If you are using our free trial, set the licenseKey to null.
      NutrientGlobal.Initialize (this, licenseKey: null);

     // Set your view from the "main" layout resource.
     SetContentView(Resource.Layout.activity_main);
   }
   ```

7. Load your PDF document and display it. This can be done just after the main activity is created in `MainActivity::OnCreate`, when a user clicks a button in a button action handler, or any time during your app’s lifecycle. You also need some code to load the file from `Assets` into your device memory. Add the following functions, which can be accessed from the `MainActivity` class.

   ```csharp

   // Read the contents of your asset.
   Android.Net.Uri GetFileFromAssets(Context ctx, string assetName)
   {
     var docPath = Path.Combine (ctx.GetExternalFilesDir (null)!.AbsolutePath, assetName);
    	if (!File.Exists (docPath)) {
    		using (var br = new BinaryReader (ctx.Assets!.Open (assetName))) {
    			using (var bw = new BinaryWriter (new FileStream (docPath, FileMode.Create))) {
    				var buffer = new byte[2048];
    				var len = 0;
    				while ((len = br.Read (buffer, 0, buffer.Length)) > 0) {
    					bw.Write (buffer, 0, len);
    				}
    			}
    		}
    	}
    	var file = new Java.IO.File (docPath);
    	return Android.Net.Uri.FromFile (file)!;
   }

   // Display the PDF you added to your assets.
   void ShowPdfDocument()
   {
      var docUri = GetFileFromAssets("Document.pdf");

      var nutrientConfiguration = new PdfActivityConfiguration.Builder(ApplicationContext).ScrollDirection(PageScrollDirection.Horizontal!).PageLabelsEnabled(true).ThumbnailGridEnabled(true).FitMode(PageFitMode.FitToWidth!).Build();

      if (!NutrientGlobal.IsOpenableUri(this, docUri))
      {
         ShowError("This document uri cannot be opened \n " + docUri.ToString());
         return;
      }

      PdfActivity.ShowDocument(this, docUri, nutrientConfiguration);
   }
   ```

8. `ShowPdfDocument()` can be called at the end of the `OnCreate` method in the generated `MainActivity.cs` code.

   ```csharp <!-- Lines inserted: [10] -->

   protected override void OnCreate(Bundle savedInstanceState)
   {
     base.OnCreate(savedInstanceState);

     // Set your `licenseKey` here and initialize Nutrient.
     NutrientGlobal.Initialize (this, licenseKey: null);

     // Set your view from the "main" layout resource.
     SetContentView(Resource.Layout.activity_main);
     ShowPdfDocument();
   }
   ```

9. Build and run your application.

## Next steps

The Nutrient.NET Mobile SDK for Android exposes the APIs from Nutrient Android SDK to.NET’s C# language. Refer to our [guides](https://www.nutrient.io/guides/android/intro.md), as they contain all the information you need to get started with Nutrient.