SfPdfViewer System.NullReferenceException (iOS)

The sfPdfViewer control does not initialize and crashes

The exception message+stacktrace is:

{System.NullReferenceException: Object reference not set to an instance of an object at Syncfusion.SfPdfViewer.XForms.SfPdfViewer.set_ShowPageNumber (System.Boolean value) [0x00024] in <236731af99274bf7a18b32d8990d96ce>:0 at App3.MainPage.InitializeComponent () [0x00012] in C:\Users\behza\source\repos\App3\App3\App3\obj\Debugetstandard2.0\MainPage.xaml.g.cs:22 at App3.MainPage..ctor () [0x00008] in C:\Users\behza\source\repos\App3\App3\App3\MainPage.xaml.cs:15 at App3.App..ctor () [0x0000f] in C:\Users\behza\source\repos\App3\App3\App3\App.xaml.cs:13 at App3.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in C:\Users\behza\source\repos\App3\App3\App3.iOS\AppDelegate.cs:26 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) [0x0003b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:85 at App3.iOS.Application.Main (System.String[] args) [0x00001] in C:\Users\behza\source\repos\App3\App3\App3.iOS\Main.cs:17 }



Visual studio 2022

Xamarin forms: 5.0.0.2401

SfPdfViewer: 20.1.0.57



Attachment: App3_a76655b6.zip


2 Replies 1 reply marked as answer

VD Vikram Devaraj Syncfusion Team May 27, 2022 07:41 AM UTC

Hi Behzad,

We were able to reproduce the issue, Using ShowPageNumber API throws NullReferenceException  . Currently, we are validating this issue and we will update the further details on May 31, 2022.


Regards,
Vikram



VD Vikram Devaraj Syncfusion Team May 31, 2022 10:36 AM UTC

Hi Behzad,

On our validation we found that this is sample level issue and to overcome this issue a
n additional step is required to render the SfPdfViewer control in iOS project. You need to call the Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init() in the FinishedLaunching overridden method of the AppDelegate class.

UG Documentation: https://help.syncfusion.com/xamarin/pdf-viewer/getting-started#creating-a-simple-pdf-viewer-application


Regards,
Vikram


Marked as answer
Loader.
Up arrow icon