Xamarin.Android annotation RemoveFromPage help - RadaeePDF.com
Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
13 Jul 2017
Microsoft has ended support for Windows Phone 8.1
Read More...
Development and suggestions about third part tool integration.
Cordova, Xamarin, Basic4Android topics are listed here.
  • Page:
  • 1

TOPIC: Xamarin.Android annotation RemoveFromPage help

Xamarin.Android annotation RemoveFromPage help 1 year 5 months ago #12441

  • digitalpages
  • digitalpages's Avatar Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
  • Posts: 3
  • Thank you received: 0
Hello, I am having trouble in removing a highlight annotation from pdf on Xamarin Android. I'm successfully able to add highlights but can't seem to figure out why removing them using RemoveFromPage() won't work.

Here are some details
  • Triple checked package name and everything related to licensing (we are using professional version).
  • Successfully implemented Xamarin.iOS adding and removing highlights. We are not mistakenly using the same package name from the iOS app :P
  • We are asking to render the page again after removing annotation.
  • We are using the latest version (at the writing of this post).

Here is some code:

NativePage is Page.Annotation class from Com.radaee.pdf
public Task<ICorePdfAnnotation> AddHighlight(ICorePdfSel selection, string color)
		{
			if (!InitObjs()) return Task.FromResult((ICorePdfAnnotation)null);

			var status = NativePage?.AddAnnotMarkup(selection.StartIndex, selection.EndIndex, 0) == true;
			ICorePdfAnnotation result = null;

			if (status)
			{
				var annotation = NativePage?.GetAnnot(NativePage.AnnotCount - 1);
				var colorObj = Color.ParseColor(color);

				annotation.SetFillColor(colorObj.ToArgb());
				annotation.SetName("Test");

				result = new AndroidPdfAnnotationWrapper(annotation);
			}

			return Task.FromResult(result);
		}
Then the wrapper class:
public class AndroidPdfAnnotationWrapper : ICorePdfAnnotation
	{
		private Page.Annotation annotation;

		public AndroidPdfAnnotationWrapper(Page.Annotation annotation)
		{
			this.annotation = annotation;
		}

		public bool Remove()
		{
			var status = annotation.RemoveFromPage();
			return status;
		}
	}
the "status" return is always false


Any other additional debugging tips you guys could share?

Thanks...

Please Log in or Create an account to join the conversation.

Xamarin.Android annotation RemoveFromPage help 1 year 5 months ago #12443

  • nermeen
  • nermeen's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 865
  • Karma: 23
  • Thank you received: 70
We have tried the below code, and we couldn't reproduce the issue:
Document document = new Document();
            if (document.Open(path, "") == 0)
            {
                bool result = false;
                Page page = document.GetPage(0);
                page.ObjsStart();
                if (page.AddAnnotMarkup(170, 616, 0))
                {
                    Page.Annotation annot = page.GetAnnot(page.AnnotCount - 1); 
                    if (annot != null)
                    {
                        result = annot.RemoveFromPage();
                    }
                }
            }
If you are not saving after adding the annotation, make sure to use the same page object, and not to close it, or you will lose your modifications.

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Powered by Kunena Forum