Adding the shape annotations programmatically gives 'Null Reference Exception' error

I am trying to add a rectangle annotation programmatically to a pdf document.


Rectangle bounds = new Rectangle(0, 0, 100, 100);

ShapeAnnotation shapeAnnotation = new ShapeAnnotation(ShapeAnnotationType.Rectangle, 1, bounds);

shapeAnnotation.Settings.StrokeColor = Color.Red;

var fileStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("CustomRenderer.Form-1040.pdf");

pdfViewerControl.LoadDocument(fileStream);

pdfViewerControl.AddAnnotation(shapeAnnotation);


The PDF loads correctly if I do not add the annotation, but produces a Null Reference Exception when I add the annotation. I can't se what part is throwing the null reference exception because it is not my code. I am using Syncfusion.Xamarin.SfPdfViewer 19.3.0.48 and Syncfusion.Xamarin.Pdf 19.3.0.48.


Edit: I think the issue is if I add the annotation in the constructor of the MainPage. If I add the annotation later, it works.


6 Replies

VD Vikram Devaraj Syncfusion Team November 11, 2021 11:49 AM UTC

Hi Casey, 
 
Greetings from Syncfusion support, 
 
We were able to reproduce the issue, “Adding shape annotation programmatically throws null reference exception” . Currently, we are validating this issue and we will update the further details on November 15, 2021. 
 
Regards, 
Vikram




VD Vikram Devaraj Syncfusion Team November 15, 2021 04:18 PM UTC

Hi Casey, 

Sorry for the inconvenience caused. We are still validating the issue, “Adding shape annotation programmatically throws null reference exception” due to the complexity of the issue. We will update the further details on November 17, 2021.

Regards,
Vikram





MP Mohana Priya Raja Syncfusion Team November 18, 2021 06:10 PM UTC

Hi Casey,  

We have confirmed that the issue “Adding shape annotation programmatically throws null reference exception” is a defect and logged a defect report for this issue. This fix will be included in our 2021 Volume 4 main release which will be available in December 2021. 
    
Please find the feedback link below,    
 
Regards, 
Mohana Priya R 



SP SarathKumar Prakash Syncfusion Team December 17, 2021 03:36 PM UTC

Hi Casey,

We sincerely regret for inconvenience caused,
We found some regression issues while testing the issue fix and because of this, we couldn't deliver as promised. This issue fix will be included in our weekly nuget package release which is expected to be available on January 4,2022.

Regards,
Sarath Kumar




SP SarathKumar Prakash Syncfusion Team January 4, 2022 03:51 PM UTC

Hi Casey   

 
We sincerely regret the inconvenience caused, 
We are still working on the issue “Adding shape annotation programmatically throws null reference exception” due to the complexity. We will provide the patch for the fix on January 11, 2022 without any further delay.   
  
Regards,  
Sarath Kumar. 



MP Mohana Priya Raja Syncfusion Team January 11, 2022 05:06 PM UTC

Hi Casey  

We have resolved the issue 
Adding shape annotation programmatically throws null reference exception
and the custom NuGet for the same can be downloaded from the following link. 
 
 
Disclaimer: Please note that we have created this NuGet for version 19.4.0.42 specifically to resolve the following issue reported in this ticket 170294 
 
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.        
https://www.syncfusion.com/kb/6987/how-to-clear-nuget-cache
 

This fix will be included in our 2021 Volume 4 service pack release which is expected to be available on January 31, 2022.

Regards,
 
Mohana Priya R 


Loader.
Up arrow icon