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

PdfPopupAnnotation localtion not showing in correct position

i've been trying the pdf annotations feature one of the is the PdfPopupAnnotation.
in your examples you have this code:

                PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(args.Bounds.Right - 18, args.Bounds.Top + 2, 1, 1),
                               "Please enter a validate interger between 1 to 50");
                popupAnnotation.Border.Width = 4;
                popupAnnotation.Open = false;
                popupAnnotation.Border.HorizontalRadius = 10;
                popupAnnotation.Border.VerticalRadius = 10;
                popupAnnotation.Icon = PdfPopupIcon.Comment;
                page.Annotations.Add(popupAnnotation);


and if i change 

new RectangleF(args.Bounds.Right - 18, args.Bounds.Top + 2, 1, 1) to new RectangleF(0, 0, 1, 1)

the annotation goes to the top left corner, as i expected.
so decided to try it on my code, but the result wasn't the same, the annotation instead of appearing in the top left corner it appeared in the bottom left corner of the first page ( file in attachment )

this is part of the code i use
first part is me loading a pdf files bytes to the viewer.

private PdfLoadedDocument pdfDocument;

// ... 

pdfDocument = new PdfLoadedDocument(bytes);
                pdfViewer.DocumentLoaded += (sender, e) =>
                {
                    try
                    {
                        pdfViewer.ViewMode = PageViewMode.FitWidth;
                    }
                    catch (Exception e1)
                    {
                        Debug.WriteLine("pdfpage.cs 128    " + e1.Message);
                    }
                };
                pdfViewer.LoadDocument(pdfDocument);


and then i have a button that when i press does this:

private async void OnSaveButtonClick(object sender, RoutedEventArgs e)
        {
            
            PdfPopupAnnotation popupAnnotation = new PdfPopupAnnotation(new RectangleF(5, 5, 5, 5), "---asdvscf 1---");
            popupAnnotation.Border.Width = 4;
            popupAnnotation.Open = true;
            popupAnnotation.Border.HorizontalRadius = 10;
            popupAnnotation.Border.VerticalRadius = 10;
            popupAnnotation.Icon = PdfPopupIcon.Comment;
            pdfDocument.Pages[0].Annotations.Add(popupAnnotation);


            var success = await UploadFile();
                        
            ShowMessageDialog("File was saved successfully!");

            Frame.Navigate(typeof(PdfPage), document);
            
        }


the only diference i see is that i use a PdfLoadedDocument instead of PdfDocument

Attachment: random_signed_fccade2c.zip

3 Replies

KK Karthik Krishnaraj Syncfusion Team April 16, 2015 01:03 PM UTC

Hi Ric,

Thank you for using syncfusion products,


We follow Cartesian co-ordinate system for adding annotations in the Pdf Loaded document,this will start the elementsrender from bottom left position,so we do not have any plan to change this behavior.

Please let me know if you need any further assistance.

Thanks,

Karthik.



RS Ric Silva April 16, 2015 03:18 PM UTC

oh i see.

But in your samples, if i change the (line 270 of the attached file)

new RectangleF(args.Bounds.Right - 18, args.Bounds.Top + 2, 1, 1),


to

new RectangleF(0,0, 1, 1),


it goes to the top left, why is that?



also another question:
is there a way to add a annotation to a selected text or to a point where i press or long press the mouse?
for example i have a long text in a pdf file and want to add a annotation to a specific word or sentence in the middle of the text. how would i accomplish that?

Attachment: InteractiveFeatures.xaml_27e6406f.zip


KK Karthik Krishnaraj Syncfusion Team April 17, 2015 11:14 AM UTC

Hi Ric,
Thank you for your patience,


But in your samples, if i change the (line 270 of the attached file)

new RectangleF(args.Bounds.Right - 18, args.Bounds.Top + 2, 1, 1),


to


new RectangleF(0,0, 1, 1),


it goes to the top left, why is that?


While creating new documents using PdfDocument instance, we convert the absolute positions (from top left) to Cartesian coordinates internally. But this is not the case for manipulating existing documents. While loading a document using PdfLoadedDocument instance, we return the actual value/bounds that has been encoded in the document. So, the coordinates while be referred from bottom left. This is the default behavior of our library.


Is there a way to add a annotation to a selected text or to a point where i press or long press the mouse?

for example i have a long text in a pdf file and want to add a annotation to a specific word or sentence in the middle of the text. how would i accomplish that?


Currently we don’t have support to find the position of the specific word in the text, hence it is not possible to add annotations to it. Whereas this could be accomplished if there is any interactive form fields in the middle of the text, so that we could get the position of that fields and then add annotations to it.


Please let us know if you have any other queries.


Thanks,
Karthik.

Loader.
Live Chat Icon For mobile
Up arrow icon