Microsoft Xamarin

Developers can use Xamarin to write native iOS, Android, and macOS apps with a shared C# codebase. We provide separate bindings for iOS and Android, as they are different SDKs that each have an API that closely matches their respective underlying system.

We offer bindings for PSPDFKit for Android and regularly update them to be compatible with new releases. A recent version of Visual Studio for Mac or Windows is required. See the project README for details.

Requirements

PSPDFKit works on Android devices running:

  • Xamarin.Android >= 9.4.1.0
  • Microsoft Mobile OpenJDK 1.8.0
  • Android 4.4 or newer / API level 19 or higher
  • 32/64-bit ARM (armeabi-v7a with NEON/ arm64-v8a) or 32/64-bit Intel x86 CPU

It’s also important that:

  • Projects using PSPDFKit.Android.dll set the target framework to API 28 (Android 9.0).
  • In Android Options, you should select d8 as your Dex compiler. Otherwise, you will get errors about default interface methods not being supported.

Using PSPDFKit via NuGet (Recommended)

  1. Right-click on your project in Visual Studio and select Manage NuGet Packages…

  2. In the Browse section of nuget.org, search for PSPDFKit.

  1. Select the PSPDFKit.Android package.

  2. Tap on Add Package to add the NuGet package to your project.

Now you are done and can skip to adding additional resources.

Building PSPDFKit.Android.dll (Advanced)

Step 1 — Get the Bindings

  1. Clone the PSPDFKit/Xamarin-Android repository from GitHub.
  2. Switch to the Xamarin-Android directory.

Step 2 — Get PSPDFKit AAR files

  1. Download PSPDFKit from the Customer Portal if you haven’t done so already, or request an evaluation version.
  2. Unzip the PSPDFKit file you downloaded above and copy pspdfkit-x.x.x.aar to the PSPDFKit.Android/Jars folder.
  3. Run the ./build.sh command (on macOS) or the ./build.ps1 command (on Windows, PowerShell) from the root directory. This will download additional resources needed by the binding. Note that running this will require you to have Xamarin already installed on your computer.

ℹ️ Note: Ensure the file is named pspdfkit-x.x.x.aar so that there is no hidden .zip file ending. macOS likes to add these extensions and doesn’t show them by default. Use the Inspector to be sure.

Visual Studio will use the default Java, but this can be customized in Preferences > SDK Locations > Java SDK (JDK).

Step 3 — Get your DLLs

You have two options for doing this.

Build from PSPDFKit.Android.sln

  1. Open PSPDFKit.Android.sln in Visual Studio.
  2. Build the project.
  3. Get the DLLs from the PSPDFKit.Android/bin folder.
  4. Enjoy.

Build from Terminal

  1. Just grab PSPDFKit.Android.dll from the root folder. If you successfully followed Step 1 from above, it should be there.
  2. Enjoy.

Now you can integrate the DLLs into your own project!

Open a PDF

Opening a PDF with PSPDFKit for Xamarin is as simple as this:

Copy
1
2
3
4
5
6
var pspdfkitConfiguration = new PdfActivityConfiguration.Builder (ApplicationContext)
	.PageMode (PSPDFPageMode.Single)
	.PageTransition (PSPDFPageTransition.ScrollContinuous)
	.ScrollDirection (PSPDFScrollDirection.Vertical)

PdfActivity.ShowDocument (this, docUri, pspdfkitConfiguration);

PSPDFKit Catalog

The PSPDFCatalog project includes various examples for pretty much every use case and will help you build your own app with PSPDFKit.

Xamarin.Forms

Xamarin.Forms does not support embedding Fragments. However, you can show a new Activity, so fullscreen PDF display is possible. See the provided Xamarin.Forms example for more details.

Xamarin.Forms does not allow hijacking the ContentPage, so by default, only fullscreen presentation is allowed. With the new Xamarin.Forms embedding, you can take any ContentPage and add it to your native applications. This technique is also showcased by our PSPDFCatalog example app.

PSPDFKit Instant

With PSPDFKit Instant, it’s easier than ever to add real-time collaboration features to your PSPDFKit-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, PSPDFKit Instant gives your users a massive productivity boost.

For more information about Instant, please take a look at our website.

To get started, you can view our Instant example here.