- Home
- Forum
- Xamarin.Forms
- Adding the shape annotations programmatically gives 'Null Reference Exception' error
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.
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
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.
We sincerely regret for inconvenience caused,
Regards,
Sarath Kumar
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.
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,
- 6 Replies
- 4 Participants
-
CF Casey Friedman
- Nov 10, 2021 04:48 PM UTC
- Jan 11, 2022 05:06 PM UTC