Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Development and suggestions about third part tool integration.
Cordova, Xamarin, Basic4Android topics are listed here.
  • Page:
  • 1

TOPIC:

Xamarin.Android annotation RemoveFromPage help 4 years 6 months ago #12441

  • digitalpages
  • digitalpages's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • 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 4 years 6 months ago #12443

  • nermeen
  • nermeen's Avatar
  • Offline
  • Platinum Member
  • Platinum Member
  • Posts: 962
  • Thank you received: 87
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.

Xamarin.Android annotation RemoveFromPage help 2 weeks 15 hours ago #15650

  • никкуз1
  • никкуз1's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Hi. What version of the license do I need to work with annotations? Now I have a standard license. I can add annotations with text selection (m_view.vSelMarkup(color, itype)). But I cannot remove them (m_view.vAnnotRemove ();). I have the same problem.

if (m_status != PDFV_STATUS.STA_ANNOT) return;
bool r = m_annot.RemoveFromPage();
vRenderSync(m_pages[m_annot_pos.pageno]);
vDraw();
vAnnotEnd();

r - always false

I do not need to save modified pdf.
I try demo licence:
bool r = PDFGlobal.ActiveLicense(2, "Radaee", "This email address is being protected from spambots. You need JavaScript enabled to view it.", "YOOW28-VS57CA-H3CRUZ-WAJQ9H-5R5V9L-KM0Y1L");
OnPDFAnnotClicked(PDFPage page, PDFAnnot annot) is not called.

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

Xamarin.Android annotation RemoveFromPage help 2 weeks 13 hours ago #15651

  • support
  • support's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 660
  • Thank you received: 53
Dear user,
    to interact and edit annotations you need an active Professional or Premium license.
You may check the trial key but you shall change your current application package name from your own to the same we use in the demo project.

 

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

  • Page:
  • 1
Powered by Kunena Forum