iOS / Android PDFTron SDK compatibility with MAUI

Since there’s no official update for the MAUI question in topic Do we have a roadmap to support on MAUI? - #8 by hofipetr85, I’ve made a quick research on my own. I’ve tried to use PDFTron in Android / iOS MAUI project targeting net7.0-android and net7.0-ios frameworks.

Both Android NuGet packages PDFTron.Android 9.4.2 and PDFTron.Android.Tools 9.4.2 are compatible with net7.0-android target framework. I was able to add the packages to the project and open a PDF document using PDFTron SDK.

iOS NuGet packages PDFTron.iOS 9.4.2 and PDFTron.iOS.Tools 9.4.2 are built for target framework xamarinios10, that is not compatible with net7.0-ios. These packages cannot be added to the MAUI project.
Nevertheless, it’s possible to make NET7 bindings on your own. NET7 and Xamaring bindings are very similar and PDFTron provides source codes of the Xamarin bindings project for PDFTron.iOS and PDFTron.iOS.Tools. So I took source codes from Xamarin bindings project and copied them in a new NET7 iOS bindings project. ApiDefinition needed these changes to be compiled successfully:

  1. Replace deprecated “IOS” attribute with “Introduced” attribute to mark API available from a specific iOS version.
  2. Remove parameters of a “Model” attribute. Protocol attributes should be only “[Protocol, Model]”
  3. Replace “UITextViewDelegate” parameter type with “IUITextViewDelegate” in UseTextViewWithText and UseTextViewWithAttributedText in the PTSelectionRectContainerView. Bindings project could be compiled without this fix, but later it fails when compiling the MAUI app.

With this custom binding I was able to view and annotate a PDF document in a MAUI iOS app.

So in the scope of a simple POC, the PDFTron SDK is compatible with MAUI.

Now the question for PDFTron team: When could we expect official support of MAUI and .NET6 / .NET7?

Best regards,
Petr Hoffman


Hi,Can i have that sample project for android in MAUI.

1 Like