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.
PSPDFKit works on Android devices running:
- Xamarin.Android >= 188.8.131.52
- 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.dllset the target framework to API 28 (Android 9.0).
- In Android Options, you should select
Dex compiler. Otherwise, you will get errors about default interface methods not being supported.
Using PSPDFKit via NuGet (Recommended)
Right-click on your project in Visual Studio and select Manage NuGet Packages…
In the Browse section of nuget.org, search for PSPDFKit.
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
- Clone the
PSPDFKit/Xamarin-Androidrepository from GitHub.
- Switch to the
Step 2 — Get PSPDFKit AAR files
- Download PSPDFKit from the Customer Portal if you haven’t done so already, or request an evaluation version.
- Unzip the PSPDFKit file you downloaded above and copy
- Run the
./build.shcommand (on macOS) or the
./build.ps1command (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
- Build the project.
- Get the DLLs from the
Build from Terminal
- Just grab
PSPDFKit.Android.dllfrom the root folder. If you successfully followed Step 1 from above, it should be there.
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:
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);
PSPDFCatalog project includes various examples for pretty much every use case and will help you build your own app with PSPDFKit.
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.
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.