Adding stamp annotation on Android

Hi,

I am trying to add button as a stamp annotation on Android in SfPdfViewer. When I try to add the button like this:

var button = new Button();
button.Text = "DEMO BUTTON";
AddStamp(button, 1, new Rectangle(10, 10, 100, 50));

then button is added to the first page. However, I need to add multiple buttons, with positions calculated at runtime. When I try to chage the code to reflect this logic, buttons are not addded into PDF.
According to logs one of the buttons which is not showing should be on second page, with coordinates x=95.79192 y=171.73758, width=239.4 and height=95.76. When I try to insert these values into previous code the button is not added.

I'm not sure where problem is, and why with some coordinates the previous code is working and with some it is not. Do you have any insight on what could be wrong? Also I have tested the code on iOS and there it is working without any issue.

Thanks in advance

22 Replies 1 reply marked as answer

MK Muralitharan Karikalan Syncfusion Team March 25, 2021 08:42 AM UTC

Hi Michal, 
 
Greetings from Syncfusion support, 
 
We were able to reproduce the issue, “AddStamp API is not working properly for particular coordinates in Xamarin.Forms Android platform ” . Currently, we are validating this issue and we will update the further details on March 29, 2021. 
 
However, I need to add multiple buttons, with positions calculated at runtime. 
Could you please provide us more details about your requirement, user case scenario and how you are getting the coordinates at run time for us to understand your requirement more and help you with better solution. 
 
Regards, 
Muralitharan K 



MS Michal Saman March 25, 2021 01:18 PM UTC

Hi,

We are using external libraries which scan the document for some keywords and return the location of these keywords. We then want to add buttons at these locations at SfPdfViewer. We do not have control over where these keyword are located, we can only guarantee that they are somewhere on the page. I have attached a sollution which you can use to replicate the issue. Code in the sollution works fine on iOS, but is not working as expected on Android.

We are in a time pressure, as one of our customers who already uses the iOS version, want's to use the Android version as well.

Thanks in advance

Attachment: SyncfusionDemo_eff0e301.zip


MK Muralitharan Karikalan Syncfusion Team March 26, 2021 12:21 PM UTC

Hi Michal, 
 
Thanks for your valuable information. As mentioned earlier, we will provide the validation details for the issue, “AddStamp API is not working properly for particular coordinates in Xamarin.Forms Android platformon March 29, 2021. 
 
Regards, 
Muralitharan K  



MK Muralitharan Karikalan Syncfusion Team March 29, 2021 03:23 PM UTC

Hi Michal,   
 
We can achieve your requirement of adding stamps with run time location using another overloading method of AddStamp. Please find the code snippet below, 
 
var button = new Button(); 
button.Text = "Demo Button"; 
Console.WriteLine("Adding Stamps"); 
 
button.WidthRequest = 96; 
button.HeightRequest = 240; 
viewer.AddStamp(button, 1, new Point(95.79192, 171.73758)); 
 
 
However, we have confirmed that the issue “AddStamp API is not working properly for particular coordinates in Xamarin.Forms Android platform” is a defect and logged a defect report for this issue. The patch for this issue will be delivered on April 19, 2021.   
   
Please find the feedback link below,   
    
Regards,   
Muralitharan K.   



MK Muralitharan Karikalan Syncfusion Team April 19, 2021 01:33 PM UTC

Hi Michal,    
    
We have resolved the issues “AddStamp API is not working properly for particular coordinates in Xamarin.Forms Android platform 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 v19.1.0.54 specifically to resolve the following issue(s) reported in this/the Forum 163833  
      
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.       
        
           
This fix will be included in our 2021 Volume 1 Service pack release which is expected to available in the month of May, 2021.        
    
Regards,    
Muralitharan K.    



MS Michal Saman April 19, 2021 11:44 PM UTC

Hi,

thanks for update. The fix you have provided is working in most cases, however I have found a scenario in which the stamp annotations are still not displayed. I have attached a sollution which you can use to replicate the issue, along with video which demonstrates how to replicate it.

The replication is a little bit tricky, first you add the stamp annotations, let's say to page 3, than you navigate to page 2 by filling the page number into the bottom bar, then you navigate to page 3 by filling the page number into the bottom bar. Now stamp annotations are not displayed on page 3. Interesting is that if you navigate to page 3 directly than stamp annotations are displayed correctly.

Unfortunatelly in our application we have a use case where we navigate page by page, which triggers this bug.

Thanks in advance

Attachment: Archive_84e896d6.zip


MK Muralitharan Karikalan Syncfusion Team April 20, 2021 10:23 AM UTC

Hi Michal, 
 
We were able to reproduce the issue, “Stamp annotation is missing while navigating between pages through toolbar in Xamarin.Forms Android platform”. But the issue occurring in a different scenario with the issue, “AddStamp API is not working properly for particular coordinates in Xamarin.Forms Android platform” which we provided the patch earlier. Currently we are validating this issue and we will update the further details on April 22, 2021. 
 
Regards, 
Muralitharan K 



MK Muralitharan Karikalan Syncfusion Team April 22, 2021 02:32 PM UTC

Hi Michal,   
    
We have confirmed that the issue “Stamp annotation is missing while navigating between pages through toolbar in Xamarin.Forms Android platform” is a defect and logged a defect report for this issue. The patch for this issue will be delivered on May 13, 2021.   
   
Please find the feedback link below,   
    
Regards,   
Muralitharan K.   



MK Muralitharan Karikalan Syncfusion Team May 13, 2021 03:07 PM UTC

Hi Michal,    
    
We have resolved the issues “Stamp annotation is missing while navigating between pages through toolbar in Xamarin.Forms Android platform” 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 v19.1.0.54 specifically to resolve the following issue(s) reported in this/the Forum 163833 
      
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.       
        
           
This fix will be included in our 2021 Volume 2 Main release which is expected to available in the month of June, 2021.        
    
Regards,    
Muralitharan K.    



MS Michal Saman May 14, 2021 10:56 AM UTC

Hi,

thanks for the update. We have tried the fix you have provided and it seems to work better. But we still have some issues on Android. On iOS we are adding stamp annotations into the document as soon as a document is loaded. We are using DocumentLoaded event for this, the code looks something like this:
sfReader.DocumentLoaded += (sender, args) =>
{
AddStamps(sfReader);
};
This does not work as expected on Android. However if we try to wait a little in the handler, the annotations are added, i.e. this code works:
sfReader.DocumentLoaded += async (sender, args) =>
{
await Task.Delay(500);
AddStamps(sfreader);
};
This is not ideal. Is this a bug or is there an another event we should use for this use case?

Also we have noticed than when we zoom the document, stamp anotations remain the same size on Android. On iOS however they zoom (get bigger) with the document. Is there some way how to achieve this on Android?

Thanks in advance



MS Michal Saman May 14, 2021 12:32 PM UTC

Also,

it seems that size of same stamp anotation is different on phone and tablet. Also the size is different when we compare it with iOS.


MK Muralitharan Karikalan Syncfusion Team May 17, 2021 05:58 PM UTC

Hi Michal, 
 
These issues are different from the issues we have provided the fix earlier. However, We were able to reproduce the issue, “Stamp annotation is not added while adding the annotation in DocumentLoaded event in Xamarin.Forms android platform” . Currently we are validating this and we will update the patch timeline details on May 19, 2021. 
 
We were unable to reproduce the issues, “Stamp annotation size not changed properly while zooming in android and Stamp annotation size are different in iOS and android” .Could you please try the below sample we have tried in our end and let us know whether we have missed out anything while replicating the issue. 
 
Please find the sample link below, 
 
Please find the attachment where the size of the stamps are same and resized properly while zooming, 
 
Kindly provide us a simple sample/modify the above sample, Replication procedure /video to reproduce the issue. 
 
Regards, 
Muralitharan K 



MS Michal Saman May 18, 2021 11:12 AM UTC

Hi,

thanks for the update. I have attached a sample where you can see the issue. I have also attached a screenshots which demonstrates our issue. You can see that the red square has different size on Phone and on Tablet. I have also attached screenshots which are zoomed, where you can see that the view is not changing it's size correctly, relative to the text in PDF. I have also attached two screenshots from iOS version, which behaves correctly.

Thanks in advance.

Attachment: Archive_3277aade.zip


MK Muralitharan Karikalan Syncfusion Team May 19, 2021 03:23 PM UTC

Hi Michal, 
 
Thanks for your update. We were able to reproduce the issue, “Stamp annotation size not changed properly while zooming and Stamp annotation size are different in tab and mobile” in Xamarin.Forms Android platform. Currently we are validating this and we will update the further details on May 21, 2021. And we have confirmed that the issue, “Stamp annotation is not added while adding the annotation in DocumentLoaded event in Xamarin.Forms Android platform” is a bug and logged a defect report for this. The patch for this issue will be delivered on June 9, 2021. 
 
Please find the feedback link below, 
 
Regards, 
Muralitharan K 



MK Muralitharan Karikalan Syncfusion Team May 21, 2021 05:09 PM UTC

Hi Michal, 
  
We have confirmed that the issue “Stamp annotation size not changed properly and size differs in tab and mobile device in Xamarin.Forms Android platform” is a defect and logged a defect report for this issue. The patch for this issue will be delivered on June 11, 2021. 
 
Please find the feedback link below, 
  
Regards 
Muralitharan K 



MS Michal Saman June 2, 2021 09:55 AM UTC

Hi,

We have found another issue in the nuget you have provided. When I try to navigate to a page with stamp annotation by setting a PageNumber property, the stamp annotations are not rendered correctly. I have attached a video where you can see the issue.

We have already had this issue in the past, and you have provided fix for it (see https://www.syncfusion.com/forums/157930/nullreferenceexception-while-adding-stamp, message from October 28th). Is it possible that this fix is not included in the Nuget available in this thread?

Thanks in advance

Attachment: stamp_bug.mov_ecef2a9b.zip


MK Muralitharan Karikalan Syncfusion Team June 3, 2021 06:19 PM UTC

Hi Michal, 
 
We were unable to reproduce the issue, “Stamp annotation is not added while navingating using page Number property” in Xamarin.Forms Android platform with the patch we have provided earlier and it is working as expected. Could you please try the below sample and let us know whether we have missed out anything while replicating the issue. 
 
Please find the sample from the below link,  
 
Please find the video where the stamp is added properly while navigating pages by PageNumber property, 
 
Kindly share us the below details to reproduce the issue from our end, 
  1. Simple sample/ modify the above sample
  2. Replication video/ procedure with the simple sample
  3. Pdf document
 
Regards, 
Muralitharan K 



MS Michal Saman June 4, 2021 01:50 PM UTC

Hi,

thanks for the reply. I tried the Sample you have provided and I was able to reproduce the issue without any modification to the code. I have attached a video where you can observe the behavior.

Additional information which may be useful. I have tried the sample on Android Emulator (Pixel C Tablet) which runs Android 11. (API 30). I have also noticed this issue on a Samsung Tablet running Android 8.

Thanks in advance

Attachment: stamp_db33cde9.zip


MK Muralitharan Karikalan Syncfusion Team June 7, 2021 07:28 AM UTC

Hi Michal, 
 
Thanks for your update. We were able to reproduce the issue, “Stamp annotation is not added while navigating using page Number property” in Xamarin.Forms Android platform with the version 19.1.0.54 from nuget.org . But this issue has been resolved in the patch ( SyncfusionNuget_19.1.0.54_948104_5132021083057529)we have provided earlier in this forum. We suspect that due to the NuGet cache was not cleared properly this issue occurred. Kindly clear the NuGet cache and install the patch NuGet we have provided to resolve this issue. 
 
To resolve the issue in your end, we have provided the demo video illustrating how to install the custom NuGet in Xamarin Forms Application. 
 
Please refer the below link to clear the NuGet cache, 
 
Regards, 
Muralitharan K  



MK Muralitharan Karikalan Syncfusion Team June 9, 2021 05:41 PM UTC

Hi Michal,    
    
We have resolved the issues “Stamp annotation is not added while adding the annotation in DocumentLoaded event in Xamarin.Forms Android platform” 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 v19.1.0.54 specifically to resolve the following issue(s) reported in this/the forum 163833  
      
Note : Kindly follow the steps to clear the NuGet cache and then install patched NuGet to get the issue resolved.       
        
           
This fix will be included in our 2021 Volume 2 Main release which is expected to available in the end of June, 2021.     
 
However, as mentioned earlier we will provide the patch for the issue, “Stamp annotation size not changed properly and size differs in tab and mobile device in Xamarin.Forms Android platform” on June 11, 2021.    
    
Regards,    
Muralitharan K.    


Marked as answer

MS Michal Saman replied to Muralitharan Karikalan June 11, 2021 01:00 PM UTC

Hi Michal, 
 
Thanks for your update. We were able to reproduce the issue, “Stamp annotation is not added while navigating using page Number property” in Xamarin.Forms Android platform with the version 19.1.0.54 from nuget.org . But this issue has been resolved in the patch ( SyncfusionNuget_19.1.0.54_948104_5132021083057529)we have provided earlier in this forum. We suspect that due to the NuGet cache was not cleared properly this issue occurred. Kindly clear the NuGet cache and install the patch NuGet we have provided to resolve this issue. 
 
To resolve the issue in your end, we have provided the demo video illustrating how to install the custom NuGet in Xamarin Forms Application. 
 
Please refer the below link to clear the NuGet cache, 
 
Regards, 
Muralitharan K  


Hi, you are correct, I was using incorrect version of your nuget. Sorry for misunderstanding.


MK Muralitharan Karikalan Syncfusion Team June 11, 2021 03:15 PM UTC

Hi Michal, 
 
Sorry for the inconvenience caused. The issue, “Stamp annotation size not changed properly and size differs in tab and mobile device in Xamarin.Forms Android platform  is not an issue with the SfPdfViewer and it can be resolved in sample level itself. We need to set the layout options for the grid and the box view. 
 
Please find the code snippet for your reference , 
 
            var grid = new Grid(); 
            grid.VerticalOptions = LayoutOptions.FillAndExpand; 
            grid.HorizontalOptions = LayoutOptions.FillAndExpand; 
            grid.ColumnDefinitions = new ColumnDefinitionCollection 
            { 
                
            }; 
            grid.RowDefinitions = new RowDefinitionCollection 
            { 
               
            }; 
            var box = new BoxView(); 
            box.VerticalOptions = LayoutOptions.FillAndExpand; 
            box.HorizontalOptions = LayoutOptions.FillAndExpand; 
            box.BackgroundColor = Color.Red; 
            grid.Children.Add(box); 
            Console.WriteLine("Adding Stamps"); 
            viewer.AddStamp(grid, 1, new Rectangle(0, 0, 100, 100)); 
 
Please find the modified sample for your reference, 
 
Regards, 
Muralitharan K 


Loader.
Up arrow icon