Installation
Add the NexPDF MAUI package, provide the native engine for each platform and declare the XAML namespace.
Install the MAUI workload
dotnet workload install mauiThe package targets net10.0-android, net10.0-ios, net10.0-maccatalyst and, when built on
Windows, net10.0-windows10.0.19041.0.
Add the package
dotnet add package Nexdevit.NexPdf.Maui --version 1.1.0Do not also reference Nexdevit.NexPdf: the MAUI package already contains NexPdfDocument and
NexPdfSdk (namespace Nexdevit.NexPdf).
Provide the native engine
Each platform needs its engine binary. The v1.1.0 release carries them:
| Platform | Release asset | Engine |
|---|---|---|
| iOS, Mac Catalyst | NexPdfCore.xcframework.zip | NexPdfCore.xcframework, linked statically (the engine is called through __Internal) |
| Android | nexpdf-android-1.1.0.aar | libnexpdf_ffi.so per ABI, under jni/<abi>/ inside the AAR (a zip archive) |
| Windows | nexpdf-ffi-1.1.0-windows-x64.zip | lib/nexpdf_ffi.dll |
When you build NexPdf.Maui from its repository (the "From source" tab above), unpack the assets
into native/ next to the project, as they unpack (since 1.0.1), or pass
-p:NexPdfNativeDir=<folder> with the same layout:
| Platform | Unpack to |
|---|---|
| iOS, Mac Catalyst | native/NexPdfCore.xcframework |
| Android | native/android/jni/<abi>/libnexpdf_ffi.so (the jni/ folder of the AAR) |
| Windows | native/windows/nexpdf_ffi.dll |
The iOS, Mac Catalyst and Android builds stop with a message naming the missing folder when the
engine for the target is not there. Inside the NexPDF source tree, when native/ has none, the
project picks the engine up from these places:
| Platform | What to build | Picked up from |
|---|---|---|
| iOS, Mac Catalyst | scripts/build-ios-xcframework.sh | sdks/swift/NexPdfCore.xcframework |
| Android | the Android SDK build | sdks/android/src/main/jniLibs/<abi>/libnexpdf_ffi.so |
| Windows | cargo build --release -p nexpdf-ffi | target/release/nexpdf_ffi.dll |
In your own app you can reference the binaries from the release directly:
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst'">
<NativeReference Include="native/NexPdfCore.xcframework">
<Kind>Static</Kind>
<ForceLoad>true</ForceLoad>
<Frameworks>Security</Frameworks>
</NativeReference>
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'android'">
<AndroidNativeLibrary Include="native/android/**/libnexpdf_ffi.so" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' == 'windows'">
<None Include="native/windows/nexpdf_ffi.dll" Link="nexpdf_ffi.dll" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>Keep the ABI folder names (arm64-v8a, x86_64, ...) under native/android/.
Declare the XAML namespace
The assembly is NexPdf.Maui and the namespace Nexdevit.NexPdf.Maui:
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:nex="clr-namespace:Nexdevit.NexPdf.Maui;assembly=NexPdf.Maui"
x:Class="MyApp.MainPage">
<nex:PdfView x:Name="Viewer" DocumentBytes="{Binding Pdf}" />
</ContentPage>Build
dotnet build -f net10.0-android