We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Getting Text and Location of annotations of a page

i have this code to add annotations to a pdf page

                    ....
                    var page = pdfDocument.Pages[pagn];
                    ....
                    string pdfAnnotationMsg = "Test Annotation 123";
                    PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF((float)x, (pageHeight * 1.325f) - (float)y - VertOff2, 5, 5), pdfAnnotationMsg);
                    popupAnnotation.Border.Width = 1;
                    popupAnnotation.Open = false;
                    popupAnnotation.Border.HorizontalRadius = 1;
                    popupAnnotation.Border.VerticalRadius = 1;
                    popupAnnotation.Icon = PdfPopupIcon.Comment;
                    page.Annotations.Add(popupAnnotation);


the annotation gets added correctly but now im trying to access to its content and location 
i have this variable :

PdfLoadedAnnotationCollection annotationCollection = pdfDocument.Pages[0].Annotations;

and its count number shows the correct ammount of annotations, but if i use
annotationCollection[0].Text
i get a exception:

"A first chance exception of type 'System.NullReferenceException' occurred in Syncfusion.Pdf.WinRT.DLL"
Exception

how do i properly get the Text and Location from the diferent Annotations ? 

4 Replies

RS Ric Silva April 23, 2015 03:47 PM UTC

forgot to mention im using version 12.2.0.36 


AS Abirami Selvan Syncfusion Team April 24, 2015 12:25 PM UTC

Hi Ric ,

Thank you for using syncfusion product .

We are unable to reproduce the issue “Getting null reference exception when load the annotation text” .We have attached the sample which we have tried to reproduce the exception in below link :

https://www.syncfusion.com/downloads/support/forum/118923/PdfAnnotationSample1637495340.zip

 

Please modify the sample or provide us the input document which you have tried to  reproduce this issue . It will help us to proceed further in this issue .

And we are able to reproduce the issue “Getting empty bounds when load the annotation location” . We will update the complete details regarding this issue on 28th April ,2015.

 

Thanks ,

Abirami.



RS Ric Silva April 24, 2015 02:35 PM UTC

ok i solved the problem some how eheh

i was loading the file to the viewer this way 

pdfViewer.DocumentLoaded += (sender, e) =>
                {
                    try
                    {
                        pdfViewer.ViewMode = PageViewMode.FitWidth;

                    }
                    catch (Exception e1)
                    {
                        Debug.WriteLine(e1.Message);
                    }
                };
                pdfViewer.LoadDocument(pdfDocument);

i replaced it with:

pdfViewer.LoadDocument(pdfDocument);
pdfViewer.ViewMode = PageViewMode.FitWidth;

and for some reason my annotation code started working


AS Abirami Selvan Syncfusion Team April 27, 2015 01:20 PM UTC

Hi Ric,

We are happy to know that the issue fixed in your side.

Please let us know if you need further assistance.

Thanks,

Abirami.


Loader.
Live Chat Icon For mobile
Up arrow icon