Xamarin

Developers can use Xamarin to write native iOS and Android 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 closely work 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 a demo from our website and then adding the PSPDFKit binary to the Xamarin binding.

Xamarin Forms users can show the PSPDFViewController in full-screen.

Building PSPDFKit.iOS.dll

Note: You must have at least Xamarin.iOS 11 and OS X 10.12.x to compile this binding project. Additionally, your Xamarin project minimum version must be 8 or later.

In order to use the bindings please follow these instructions:

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. Download PSPDFKit from your customer portal if you haven't done so already.
  2. Open the dmg file you downloaded in step 1 and copy PSPDFKit.framework to the PSPDFKit.iOS folder and PSPDFKitUI.framework to the PSPDFKit.iOS.UI folder.

Optional: Copy Instant.framework to the PSPDFKit.iOS.Instant folder.

This binding provides Unified Api support out of the box.

Step 3 - Get your Dll

You have two options to get it:

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, this allows us to build on both Windows and Mac from a single script.

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

Step 4 - Integrating Into Your Project

  1. Add a reference of PSPDFKit.iOS.dll and PSPDFKit.iOS.UI.dll to your project.
  2. Add the following namespaces to your project, depending on what you need:
1
2
3
using PSPDFKit.Core;
using PSPDFKit.UI;
using PSPDFKit.Instant;

Set the License Key

Call PSPDFKitGlobal.SetLicenseKey("YOUR_LICENSE_KEY_GOES_HERE"); early on in your AppDelegate, 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);

Stylus Support

PSPDFKit for iOS includes support for all major stylus vendors, including the Apple Pencil.
How to integrate the stylus drivers into your Xamarin app is explained here.