{"id":26086859,"url":"https://github.com/pspdfkit/dotnet-pdf-library-for-android","last_synced_at":"2025-04-12T03:23:16.728Z","repository":{"id":205092127,"uuid":"657960600","full_name":"PSPDFKit/dotnet-pdf-library-for-android","owner":"PSPDFKit","description":"How to build a PDF Viewer and Editor for iOS using .NET (C#) with PSPDFKit.NET (Android).","archived":false,"fork":false,"pushed_at":"2025-03-19T06:09:15.000Z","size":4391,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-03-19T06:32:08.520Z","etag":null,"topics":["android","csharp","dotnet","maui","net-android","pdf","pdf-editor","pdf-viewer"],"latest_commit_sha":null,"homepage":"http://pspdfkit.com","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PSPDFKit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-24T10:33:14.000Z","updated_at":"2025-03-11T08:10:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"fa95fb27-9548-42ba-8aee-0679a2761e8b","html_url":"https://github.com/PSPDFKit/dotnet-pdf-library-for-android","commit_stats":null,"previous_names":["pspdfkit/dotnet-pdf-library-for-android"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fdotnet-pdf-library-for-android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fdotnet-pdf-library-for-android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fdotnet-pdf-library-for-android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit%2Fdotnet-pdf-library-for-android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSPDFKit","download_url":"https://codeload.github.com/PSPDFKit/dotnet-pdf-library-for-android/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248510794,"owners_count":21116277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","csharp","dotnet","maui","net-android","pdf","pdf-editor","pdf-viewer"],"created_at":"2025-03-09T07:18:37.825Z","updated_at":"2025-04-12T03:23:16.698Z","avatar_url":"https://github.com/PSPDFKit.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nutrient.NET (Android)\n\n.NET for Android C# Bindings for Nutrient `v10.0.2`.\n\n#### Nutrient\n\nThe [Nutrient SDK](https://nutrient.io/) is a framework that allows you to view, annotate, sign, and fill PDF forms on iOS, Android, Windows, macOS, and Web.\n\n[Nutrient Instant](https://www.nutrient.io/guides/android/instant-synchronization/) adds real-time collaboration features to seamlessly share, edit, and annotate PDF documents.\n\n#### Related\n\n- Nutrient.NET (iOS): [PSPDFKit/dotnet-pdf-library-for-ios](https://github.com/PSPDFKit/dotnet-pdf-library-for-ios)\n- Nutrient.NET for mobiles (iOS \u0026 Android): [PSPDFKit/dotnet-pdf-library-for-mobiles](https://github.com/PSPDFKit/dotnet-pdf-library-for-mobiles)\n\n## Support, Issues and License Questions\n\nNutrient offers support via https://nutrient.io/support/request/.\n\nAre you evaluating our SDK? That's great, we're happy to help out!\nTo make sure this is fast, please use a work email and have someone from your company fill out our sales form: https://www.nutrient.io/contact-sales\n\n## Requirements\n\nNutrient runs on Android devices running:\n\n* **NET for Android workload \u003e= 33.0.95/7.0.100**\n* **Microsoft Mobile OpenJDK \u003e= 11.0**\n* Android **5** or newer / API level **21** or higher\n* 32-bit or 64-bit ARM (armeabi-v7a with NEON / arm64-v8a) or 32-bit or 64-bit Intel x86 CPU.\n* Projects using Nutrient.dotnet.Android.dll **must** set [Target Framework](https://developer.xamarin.com/guides/android/application_fundamentals/understanding_android_api_levels/#framework) to **API 33 (Android 13.0)** or higher.\n\n## Integrating Nutrient\n\nThere's 2 ways to integrate Nutrient into your project. We highly recommend using our nuget packages from nuget.org in Visual Studio as it requires less work for the customer and also eliminates the possibility of build errors, which can happen from time to time.\n\n### Integrating Nutrient via NuGet (Recommended)\n\n1. Right-Click on your project in Visual Studio and select \"Manage NuGet Packages...\"\n2. In the `Browse` section for \"nuget.org\" search for \"Nutrient.dotnet\":\n\n\u003cimg width=\"70%\" src=\"Images/Add-NuGet-package.png\"/\u003e\n\n3. Select the `Nutrient.dotnet.Android` package.\n4. Tap on \"Add Package\" to add the NuGet package to your project.\n\nNow you are done and can skip to [Adding additional resources](https://github.com/PSPDFKit/dotnet-android#adding-additional-resources)!\n\n### Integrating Nutrient via DLLs (Advanced)\n\n#### Step 1 - Get Nutrient .aar File\n\nRun `./build.sh` (on macOS) or `./build.ps1` (on Windows, PowerShell) command from root directory. This will download all the required resources needed by the binding. Note that running this will require you to have [The android workload](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-workload-install) already installed on your computer.\n\n**💡 Note:** Ensure the files are really named `Nutrient-Android-SDK-AAR-x.x.x.aar` so there is no hidden `.zip` file ending. OS X likes to add these things and doesn't show them by default. Use the Inspector to be sure.\n\nVisual Studio will use the default Java, but this can be customized in Preferences -\u003e SDK Locations -\u003e Java SDK (JDK).\n\n#### Step 2 - Get your Dlls\n\nYou have two options to get it:\n\n#### Build from Nutrient.dotnet.Android.sln\n\n1. Open `Nutrient.dotnet.Android.sln` in `Visual Studio`.\n2. Build the project.\n3. Get the dll from the `Nutrient.dotnet.Android/bin` folder.\n4. Enjoy.\n\n#### Build from Terminal\n\n1. Just grab `Nutrient.dotnet.Android.dll` from the `Nutrient.dotnet.Android/bin` folder, if you successfuly followed **Step 1** it should be there.\n2. Enjoy.\n\n#### Integrating the dlls into your own Project\n\nIn order to use **Nutrient.dotnet.Android.dll** with your own project you will need to add the dll as a reference to your project. You can achieve this by doing the following:\n\n1. Right click in your **References** folder from your project and select **Edit References...**\n2. Select **.Net Assembly** tab and click **Browse**\n3. Locate your **Nutrient.dotnet.Android.dll** copy and add it.\n\n## Usage\n\nNutrient can display documents either in a new Activity or a Fragment you include into your hierarchy.\n\nNote that currently only local files are supported for Nutrient.\n\n### Checking for Compatibility\n\nYou can include Nutrient into applications which will be distributed to devices not supported by Nutrient. In that case you can attempt initializing and catch `PSPDFKitInitializationFailedException` to check for device compatibility.\n\n* Initialize Nutrient early in your application lifecycle. You can get your license key from your [customer portal](https://my.nutrient.io/) if you haven't done so already. Pass `null` to use the trial version.\n\n```csharp\ntry {\n\tPSPDFKitGlobal.Initialize(this, licenseKey: null);\n} catch (PSPDFKitInitializationFailedException ex) {\n\tConsole.WriteLine (\"Current device is not compatible with Nutrient: {0}\", ex.Message);\n}\n```\n\n### Display Nutrient Activity\n\n* Add Nutrient viewer activity to your applications **AndroidManifest.xml**\n\n```xml\n\u003capplication android:largeHeap=\"true\"\u003e\n    \u003cactivity android:name=\"com.pspdfkit.ui.PdfActivity\"\n              android:windowSoftInputMode=\"adjustNothing\" /\u003e\n\u003c/application\u003e\n```\n\n\u003eYou can use android:theme attribute to customize actionbar, background and other elements of the activity theme if you so desire.\n\n* Make sure you have `android:largeHeap=\"true\"` property in your `\u003capplication\u003e` tag in **AndroidManifest.xml**. Rendering PDF files is memory intensive and this property will ensure your app has enough heap allocated to avoid out of memory errors.\n\n* Create `PdfActivityConfiguration` object and then call `PdfActivity.ShowDocument()` to display the document. Document location is expressed with an Uri object.\n\n```csharp\nvar pdfDocument = Android.Net.Uri.FromFile (new Java.IO.File (Android.OS.Environment.ExternalStorageDirectory, \"document.pdf\"));\nvar configuration = new PdfActivityConfiguration.Builder(ApplicationContext)\n            .ScrollDirection(PageScrollDirection.Horizontal)\n            .PageLabelsEnabled(true)\n            .ThumbnailGridEnabled(true)\n            .FitMode(PageFitMode.FitToWidth)\n            .Build();\nPdfActivity.ShowDocument(this, pdfDocument, configuration);\n```\n\n\u003eYou can create an Uri object from file using `Android.Net.Uri.FromFile(File)` call or you can pass in Uri returned by [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider.html). For all configuration options refer to included JavaDoc.\n\n### Display Nutrient Fragment\n\n* Make sure you have `android:largeHeap=\"true\"` property in your `\u003capplication\u003e` tag in **AndroidManifest.xml**. Rendering PDF files is memory intensive and this property will ensure your app has enough heap allocated to avoid out of memory errors.\n\n```xml\n\u003capplication android:largeHeap=\"true\"\u003e\n    ...\n\u003c/application\u003e\n```\n\n* Create `PdfConfiguration` object and then call `PdfFragment.NewInstance()` to create a new `PdfFragment` instance for a document.\n* Attach the fragment to your view hierarchy. Remember that fragments are retained over configuration changes, so do not recreate fragment if it's already attached - that will lead to bugs and out of memory errors.\n\n```csharp\nvar pdfDocument = Android.Net.Uri.FromFile (new Java.IO.File (Android.OS.Environment.ExternalStorageDirectory, \"document.pdf\"));\nvar configuration = new PdfActivityConfiguration.Builder(ApplicationContext)\n            .ScrollDirection(PageScrollDirection.Horizontal)\n            .PageLabelsEnabled(true)\n            .ThumbnailGridEnabled(true)\n            .FitMode(PageFitMode.FitToWidth)\n            .Build();\n\nvar fragment = PdfFragment.NewInstance(pdfDocument, configuration);\nSupportFragmentManager.BeginTransaction().Replace(Resource.Id.Content, fragment).Commit();\n```\n\n\u003e Note that the `PdfFragment` extends `AndroidX.Fragment.App.Fragment` and not `Android.App.Fragment`.\n\n### Render Page to a Bitmap\n\nYou can use Nutrient to render PDF to bitmaps without showing them in activities. To do that, use `PSPDFKitGlobal` and `PdfDocument` class calls.\n\nExample:\n\n```csharp\ntry {\n\tvar pdfDocument = PSPDFKitGlobal.OpenDocument (this, Android.Net.Uri.FromFile (new Java.IO.File(Android.OS.Environment.ExternalStorageDirectory, \"document.pdf\")));\n\tvar pageToRender = 1; // This is 0-indexed, use pdfDocument.PageCount to retrieve number of pages\n\tvar pageBitmap = pdfDocument.RenderPageToBitmap(this,\n\t\tpageToRender,\n\t\t// This is the size of bitmap that will be generated\n\t\tpdfDocument.GetPageSize (pageToRender).Width,\n\t\tpdfDocument.GetPageSize (pageToRender).Height);\n} catch (IOException ex) {\n\tConsole.WriteLine (\"Failed to open PDF document: {0}\", ex.Message);\n}\n```\n\n### Customization\n\nTo customize `PdfActivity` UI elements, use theme based on `Theme.AppCompat`. Nutrient will color actionbar and other elements according to `colorPrimary` and `colorAccent` attributes. Example theme definition:\n\n```xml\n\u003cstyle name=\"MyApplicationTheme.Theme\" parent=\"Theme.AppCompat.Light.DarkActionBar\"\u003e\n    \u003citem name=\"colorPrimary\"\u003e@color/mymain_color\u003c/item\u003e\n    \u003citem name=\"colorPrimaryDark\"\u003e@color/mymain_color_dark\u003c/item\u003e\n    \u003citem name=\"colorAccent\"\u003e@color/mymain_color_accent\u003c/item\u003e\n\u003c/style\u003e\n```\n\nAnd then it should be applied in AndroidManifest.xml:\n\n```xml\n\u003cactivity android:name=\"com.pspdfkit.ui.PdfActivity\"\n      android:windowSoftInputMode=\"adjustNothing\"\n      android:theme=\"@style/MyApplicationTheme.Theme\" /\u003e\n```\n\nOther configuration options for UI elements (icons, element sizes) can be found in `PdfActivityConfiguration` class.\n\n### More Information\n\nFor more documentation about Nutrient check out [Nutrient online documentation](https://www.nutrient.io/guides/android/) and bundled Javadoc.\n\n# Nutrient Instant\n\nWith Nutrient Instant, it’s easier than ever to add real-time collaboration features to your Nutrient-powered app, allowing your users to seamlessly share, edit, and annotate PDF documents across iOS, Android, and web. With just a few lines of code, Nutrient Instant gives your users a massive productivity boost.\n\nFor more information about Instant, please have a look at our [website](https://www.nutrient.io/guides/android/instant-synchronization/).\n\n# Examples\n\nYou can find several sample projects in the `samples` folder.\n\n### AndroidSample\n\n`AndroidSample` is an example project showing showing how to open and present document, or how to open a document from various file providers or the local file directory.\n\n### Contributing\n\nPlease ensure [you signed our CLA](https://www.nutrient.io/guides/web/miscellaneous/contributing/) so we can accept your contributions.\n\n[Instant Example]: https://github.com/PSPDFKit/Xamarin-Android/tree/master/samples/PSPDFCatalog/Catalog/Instant\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspdfkit%2Fdotnet-pdf-library-for-android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpspdfkit%2Fdotnet-pdf-library-for-android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpspdfkit%2Fdotnet-pdf-library-for-android/lists"}