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

iOS Negatives Coordinates

Recently I used the pdf controls and I got something weird with iOS coordinates. Using the below function in an Android device I got the correct coordinates, but if I use an iOS device the coordinates aren't the same. For example, using Android device I got 

{{X=177.4717,Y=227.54,Width=66.04127,Height=11.04}}

and using iOS device:

{{X=17747,17,Y=-6047,08,Width=6604,129,Height=1104}}.

X, Width and Height are 100 times the same but Y coordinate doesn't make sense for me. It's a negative coordinate and I couldn't find the relationship with the others.

How do you get the Y coordinate in a iDevice?

Hope you can help me.


Regards.



        public static MemoryStream HighLightPdf(this byte[] bytes, Dictionary<string, IList<string>> words)
        {
            Color color = Color.Yellow;

            PdfLoadedDocument doc = new PdfLoadedDocument(bytes);
            Dictionary<int, List<RectangleF>> matchRect = new Dictionary<int, List<RectangleF>>();

            foreach (var key in words.Keys)
            {
                if (key == "Locations")
                    color = Color.Blue;
                else if (key == "Organizations")
                    color = Color.Red;
                else if (key == "People")
                    color = Color.Green;

                foreach (var word in words[key])
                {
                    var matched = doc.FindText(word, out matchRect);
                    if (matched)
                    {
                        foreach (KeyValuePair<int, List<RectangleF>> item in matchRect)
                        {
                            PdfLoadedPage page = doc.Pages[item.Key] as PdfLoadedPage;
                            foreach (var rect in item.Value)
                            {

                                PdfTextMarkupAnnotation textannot = new PdfTextMarkupAnnotation(newRect);
                                textannot.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight;
                                textannot.TextMarkupColor = new PdfColor(color);
                                page.Annotations.Add(textannot);
                            }
                        }
                    }
                }
            }
            MemoryStream memStream = new MemoryStream();
            doc.Save(memStream);
            return memStream;
        }

3 Replies

KK Karthik Krishnaraj Syncfusion Team November 1, 2018 02:23 PM UTC

Hi Laura, 
 
Greetings from Syncfusion, 
 
We were unable to reproduce the issue with provided information. We are getting the coordinate value of searched text same as in android. I have attached a sample which we tried in our side. Can you please modify the sample to replicate the issue and share with us? It will be helpful for us to analyze further and provide better solution. 
 
Sample Link: 
 
Regards, 
Karthik. 



LA laura November 2, 2018 08:59 AM UTC

We've tested the program on the emulator and on the devices and the results obtained were different. When testing on the emulator, coordinates are correct but trying it on the device, either Android or iOS,  coordinates are wrong.


DB Dilli Babu Nandha Gopal Syncfusion Team November 5, 2018 11:46 AM UTC

Hi Laura, 

We are afraid that we are unable to reproduce the issue “Bounds of the specified text is not approximate in emulator and device” while deploying the application in Xamarin.Forms Android and Xamarin.Forms iOS. We suspect that the issue is specific to the PDF document. So, we request you to share us the PDF document with which the issue could be reproduced. 
  
Note: If you have any confidential data in your PDF document, please replace with some dummy data and provide us the same. Kindly check whether the issue is reproduced with this document We just need your document to recreate the problem you face. 
 
Also provide the following details which will help us to reproduce the issue, 

  1. Device details (Android/iOS) with model name 
  2. Syncfusion Essential Studio 
  3. Device culture information 
  4. Issue reproducing sample 

Please let us know if you have any questions. 

Regards, 
Dilli babu. 


Loader.
Live Chat Icon For mobile
Up arrow icon