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 and have an API that closely matches the underlying system.

PSPDFKit for iOS

PSPDFKit for iOS includes full-featured bindings for Xamarin (formerly called MonoTouch). We work closely with Xamarin to provide up-to-date bindings shortly after the regular PSPDFKit releases. These bindings allow extensive customization and subclassing.

You can try the demo by requesting it from our website and then adding the PSPDFKit binary to the Xamarin binding.

Xamarin.Forms users can show the PDFViewController in fullscreen mode.

ℹ️ Note: You must have at least Xamarin.iOS 13.x and macOS 10.15.x to compile this binding project. Additionally, your Xamarin project minimum iOS version must be 11 or later.

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 three iOS packages: PSPDFKit.iOS.Model, PSPDFKit.iOS.UI*, and PSPDFKit.iOS.Instant*.

  2. Tap on Add Packages to add the NuGet packages to your project.

* Items with an asterisk are optional, and you only need to add them if you also want to use their functionality.

Now you are done and can skip to integrating PSPDFKit into your project.

Building PSPDFKit.iOS.dll (Advanced)

In order to use the bindings, please follow the instructions below.

Step 1 — Get the Bindings

  1. Clone the PSPDFKit/Xamarin-iOS repository from GitHub.
  2. Switch into the Xamarin-iOS directory.

Step 2 — Get PSPDFKit and Copy the Required Files

  1. In order to use this C# binding, because Xamarin does not support xcframework yet, you will need to download the full PSPDFKit framework files from the following links (replace 9.x.x with the current version number), or request an evaluation version.
  2. Extract the ZIP files and copy the following files into the specified directories:

iOS — from the PSPDFKit-for-iOS ZIP

  • Copy PSPDFKit.framework into the PSPDFKit.iOS.Model folder.
  • Copy PSPDFKitUI.framework into the PSPDFKit.iOS.UI folder. *
  • Copy Instant.framework into the PSPDFKit.iOS.Instant folder. *

macOS — from the PSPDFKit-for-macOS DMG

  • Copy PSPDFKit.framework into the PSPDFKit.Mac.Model folder. *

Items with an asterisk (*) are optional. If you do not provide a framework, by default, we won’t generate its bindings. However, most of the time you will want to provide at least PSPDFKit.framework and PSPDFKitUI.framework.

If you’re on Windows, the free 7-Zip file archiver can unpack DMG files.

This binding provides Unified API support out of the box.

Step 3 — Get the DLL

You have two options for getting the DLL.

Using Visual Studio for Mac or Windows

  1. Open PSPDFKit.sln, which is located in the root folder.
  2. Build the iOS project inside the solution.
  3. Get the DLL from the bin folder of each project.

Using the Command Line / Terminal

We are using Cake as our build system, as this allows us to build on both Windows and macOS from a single script.

  1. Just run the ./build.sh command (macOS) or the .\build.ps1 command (Windows) from the root directory.
  2. All the resulting DLLs will be inside the root folder.

Integrate into Your Project

If you don’t use NuGet, add the generated PSPDFKit DLLs to your own Xamarin project as a reference and add the corresponding using statements (depending on the DLLs referenced) into your project:

1
2
3
using PSPDFKit.Model;
using PSPDFKit.UI;
using PSPDFKit.Instant;

Set the License Key

Call PSPDFKitGlobal.SetLicenseKey("YOUR_LICENSE_KEY_GOES_HERE"); early on in your app delegate, before accessing any other PSPDFKit classes.

Open a PDF

Copy
1
2
3
4
5
6
7
8
var configuration = PSPDFConfiguration.FromConfigurationBuilder ((builder) => {
	builder.PageMode = PSPDFPageMode.Single;
	builder.PageTransition = PSPDFPageTransition.ScrollContinuous;
	builder.ScrollDirection = PSPDFScrollDirection.Vertical;
}));

var document = new PSPDFDocument (NSUrl.FromFilename ("document.pdf"));
var pdfViewController = new PSPDFViewController (document, configuration);

PSPDFKit Catalog Example

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

Xamarin.Forms

We also support Xamarin.Forms and have a great example project that shows how to build an app with PSPDFKit using Xamarin.Forms. To run this example, follow the steps provided in the Xamarin-iOS repo.

PSPDFKit Instant

Support for Instant was added with the PSPDFKit 7.2.0 for iOS Xamarin Bindings.

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 have a look at our website.

To get started, you can take a look at our Instant example here.