Microsoft Xamarin - Stylus Support

After successfully building PSPDFKit.iOS.dll you can add stylus support to the framework by following these steps:

Step 1 - Copy required files

  1. Copy PSPDFKit.framework and PSPDFKitUI.framework into StylusDrivers/externals.
  2. Copy Extras/StylusSupport/Drivers (you can find this folder in the dmg you downloaded from your customer portal) into StylusDrivers/externals.

Step 2 - Add stylus SDKs

  1. Visit our stylus support documentation for a list of supported styluses and download links for the vendor SDKs.
  2. After downloading the vendor SDKs (.framework and .bundle files) you integrate them by moving them into StylusDrivers/externals.

Step 3 - Building the stylus drivers

  1. Switch to the Xamarin-iOS/StylusDrivers folder in a terminal.
  2. You can see all available build options by running $ make.
  3. To build all drivers call $ make alldrivers. To build individual drivers call $ make adonit for example.
  4. The compiled driver Dlls will be placed in the Xamarin-iOS/StylusDrivers folder.

Step 4 - Integrating the stylus drivers

1. Start by adding the compiled driver DLLs into the project reference:

Afterwards your directory structure should look like this:

2. Add the following into your Xamarin.iOS project:

using PSPDFKit.UI.StylusSupport;

3. Register the driver classes: Before creating a PSPDFViewController, register the driver classes by calling PSPDFKitGlobal.SharedInstance.GetStylusManager ().AvailableDriverClasses.

PSPDFKitGlobal.SharedInstance.GetStylusManager ().AvailableDriverClasses = new NSOrderedSet (
	(INativeObject) new Class (typeof (PSPDFAdonitStylusDriver))

If you use PSPDFAnnotationToolbar, show the stylus button by setting ShowingStylusButton to true.

To see this in action, you can take a look at our PSPDFCatalog example. The example code is located in the DVCMenu.cs file.

Step 5 - Test stylus support

Our sample project PSPDFCatalog contains an example called “Stylus Support” that adds a stylus button the annotation toolbar:

After pressing this button you should see a list of all the stylus types you added drivers for: