- Home
- Forum
- Xamarin.Forms
- NullReferenceException while adding stamp.
NullReferenceException while adding stamp.
Hi,
I'm currently trying to learn about Syncfusion's PDFViewer for Xamarin forms. While following the tutorial for adding custom view into the PDF, NullReferenceException is thrown and the app crashes. This happens on both, iOS and Android.
This is my demo code:
protected override void OnAppearing()
{
base.OnAppearing();
var stream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("PdfReaderDemo.Assets.TestDoc.pdf");
PdfReader.OpenDoc(stream);
Image image = new Image();
image.Source = ImageSource.FromResource("PdfReaderDemo.Assets.Image.png", typeof(App).GetTypeInfo().Assembly);
image.WidthRequest = 200;
image.HeightRequest = 100;
PdfReader.AddStamp(image, 1, new Rectangle(10, 10, 100, 100));
}
PDFReader is SfPdfViewer object.
Is this a bug in SfPdfViewer or am I missing something? Thanks in advance.
SIGN IN To post a reply.
17 Replies
1 reply marked as answer
AV
Ashokkumar Viswanathan
Syncfusion Team
September 18, 2020 11:24 AM UTC
Hi Michal,
Greetings from Syncfusion support,
We are able to reproduce the issue “Application crashes with null reference exception while adding stamp annotation”. Currently, we will validating the issue and the validation details will be updated on September 22nd , 2020.
Regards,
Ashok Kumar Viswanathan.
NK
Navaneetha Kannan Sudalai Muthu
Syncfusion Team
September 22, 2020 06:33 PM UTC
Hi Michal,
We confirm that the issue “Application crashes with null reference exception while adding stamp annotation” is a defect. The patch for the fix will be updated on October 13, 2020.
Please find the feedback link below.
Best,
Navaneetha Kannan
AV
Ashokkumar Viswanathan
Syncfusion Team
October 13, 2020 06:07 PM UTC
Hi Michal,
We have resolved the issue, “Application crashes with null reference exception while adding stamp annotation” and the custom NuGet for the same can be downloaded from the following link
Custom NuGet :
Please find the feedback link below,
Disclaimer:
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in the above mentioned forum. 157930
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in the above mentioned forum. 157930
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.
This fix will be included in our 2020 Volume 3 Service pack release which will be available in the month of November 2020.
Regards,
Ashok Kumar Viswanathan.
MS
Michal Saman
October 14, 2020 12:19 PM UTC
Hi,
I have tried using the nuget package you have provided. Issue seems solved on iOS (tested in simulator), but persists on Android. Same code which now runs on iOS doesn't run on Android.
Thanks in advance.
AV
Ashokkumar Viswanathan
Syncfusion Team
October 15, 2020 12:08 PM UTC
Hi Michal,
We have checked the provided patch for the issue, “Application crashes with null reference exception while adding stamp annotation” in Android Platform, but its working as expected.
Kindly refer the sample and screenshot in the below link for the resultant output.
We suspect that the NuGet packages with fix are not installed properly, so kindly follow the steps to clear the NuGet cache and then install patched NuGet again to get this issue resolved.
If you are still facing the issue, Kindly share the following details to analyze more on this issue and assist you with the better solution.
- Simple sample/ modify the above sample(if any changes)
- Android device specification.
- Replication procedure/video illustrating the issue in detail.
Regards
Ashok Kumar Viswanathan.
MS
Michal Saman
October 20, 2020 11:19 AM UTC
Hi,
Attachment: GettingStarted_modified_66353cae.zip
this took a while to debug, but I was able to replicate the bug even in the code you have provided. I'm 100% sure that the NuGet you have provided is installed in the solution but the error is still occurring.
Anyway, it seems that adding stamps is not working while the stamp is added to the page which is not currently displayed to the user. I took the sample code you provided and changed the page from 1 to 4. This throws a NullReferenceException. I attach the modified solution.
Only change I have done to it is that I have modified file GettingStarted/PDFViewerPage.xaml.cs on line 41.
Changed from:
pdfViewerControl.AddStamp(image, 1, new Xamarin.Forms.Rect(10, 10, 100, 100));
To:
pdfViewerControl.AddStamp(image, 4, new Xamarin.Forms.Rect(10, 10, 100, 100));
And the exception occurs.
This happens in Android simulator and on physical device, both running Android 10.
Regards
Attachment: GettingStarted_modified_66353cae.zip
AV
Ashokkumar Viswanathan
Syncfusion Team
October 21, 2020 02:16 PM UTC
Hi Michal,
Thank you for your update,
We will resolve the issue and provide patch on October 22nd, 2020.
Regards,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
October 22, 2020 05:28 PM UTC
Hi Michal,
Thank you for the patience,
We have resolved the issue, ”Application crashes with null reference exception while adding stamp annotation” and the custom NuGet for the same can be downloaded from the following link
Custom NuGet :
Disclaimer:
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in this/the forum. 157930.
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in this/the forum. 157930.
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.
This fix will be included in our 2020 Volume 3 service pack release which is expected to available in the month of November, 2020.
Regards,
Ashok Kumar Viswanathan.
Marked as answer
MS
Michal Saman
October 23, 2020 08:16 AM UTC
Hi,
thanks for the patch, I can confirm that now the AddStamp method does not throw an exception on Android. However sometimes stamps are not displayed at all. This happens when I try to navigate to page through code by setting the PageNumber property on SfPdfViewer. If I go to page by scrolling, stamps are displayed correctly. This is an Android only thing, on iOS everything seems to work fine.
I'm sure that I have installed your patch correctly, with clearing Nuget cache.
Best Regards
AV
Ashokkumar Viswanathan
Syncfusion Team
October 26, 2020 12:09 PM UTC
Hi Michal,
Thank you for your update,
We will resolve the issue reported in your last update and provide patch on October 27th , 2020.
Regards,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
October 27, 2020 07:16 PM UTC
Hi Michal,
Sorry for the inconvenience caused,
We will resolve the issue reported in your last update and provide patch on October 28th , 2020.
Regards,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
October 28, 2020 12:55 PM UTC
Hi Michal,
Thank you for the patience,
We have resolved the issue, ”Stamp is not added properly while using page number property” and the custom NuGet for the same can be downloaded from the following link
Custom NuGet :
Disclaimer:
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in this/the forum. 157930.
Please note that we have created this NuGet for version 18.3.0.35 specifically to resolve the following issue(s) reported in this/the forum. 157930.
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.
This fix will be included in our 2020 Volume 4 main release which is expected to available in the month of December, 2020.
Regards,
Ashok Kumar Viswanathan.
MS
Michal Saman
October 29, 2020 09:38 AM UTC
Hi,
thanks for the fix, everything seems to work now. One last thing I noticed regarding Stamps is that the units used across iOS and Android are not consistent. When I add a stamp, the position is different on iOS and Android. Points are used on iOS, I couldn't determine which units are used on Android. I couldn't find any documentation regarding this, so I don't know if this is a bug or feature. It is no big deal for me, just letting you know.
I attached a screenshot of Android and iOS simulators, both running same code, notice the relative position of purple stamp to the rest of the document. This is the code which adds the stamp to the page:
AddStamp(view, 4, new Point(50, 692));
Regards
Attachment: Screenshot_20201029_at_10.28.26.png_b849ffbe.zip
SP
Satheesh Palanisamy
Syncfusion Team
October 30, 2020 01:57 PM UTC
Hi Michal,
Greetings from Syncfusion support,
We were able to reproduce the issue, “Bounds of the added stamp added is not same for all the platforms”. Currently, we are validating the issue and we will update the further details on November 3rd, 2020.
Regards,
Satheesh Palanisamy.
SP
Satheesh Palanisamy
Syncfusion Team
November 3, 2020 04:57 PM UTC
Hi Michal,
We confirm that the issue " Bounds of the added stamp are not the same on all the platforms" is a defect. The patch for the fix will be updated on November 24th, 2020.
Please find the feedback link below.
Regards,
Satheesh Palanisamy.
AV
Ashokkumar Viswanathan
Syncfusion Team
November 24, 2020 03:15 PM UTC
Hi Michal,
Sorry for the inconvenience caused. We are still working on the issue “Bounds of the added stamp are not the same on all the platforms” and we will provide the patch for the fix on December 1st , 2020 without any further delay.
Best,
Ashok Kumar Viswanathan.
AV
Ashokkumar Viswanathan
Syncfusion Team
December 1, 2020 02:05 PM UTC
Hi Michal,
We have resolved the issue ”Bounds of the added stamp are not the same on all the platforms” and the custom NuGet for the same can be downloaded from the following link
Custom NuGet :
Disclaimer:
Please note that we have created this NuGet for version 18.3.0.52 specifically to resolve the following issue(s) reported in this/the Forum 157930
Please note that we have created this NuGet for version 18.3.0.52 specifically to resolve the following issue(s) reported in this/the Forum 157930
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.
This fix will be included in our 2020 Volume 4 Service pack release which is expected to available in the month of January, 2021.
Regards,
Ashok Kumar Viswanathan
SIGN IN To post a reply.
- 17 Replies
- 4 Participants
- Marked answer
-
MS Michal Saman
- Sep 17, 2020 12:39 PM UTC
- Dec 1, 2020 02:05 PM UTC