Signin/Signup with: 
Welcome, Guest
Username: Password: Remember me
Questions about Android development and PDF
  • Page:
  • 1

TOPIC:

Delete highlight from page 6 years 6 months ago #12913

  • vlad91
  • vlad91's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
Hello,
I'm trying to delete highlights. I get a reference to the annotation using document.GetPage(pageno).GetAnnot(index) and the I call RemoveFromPage(), however this method returns false. I'm sure that the license setup is correct, selection and highlighting work as expected.
I also noticed that document.CanSave() is always false!

Can some help me please?

Kind regards,
Vlad
Last edit: by vlad91.
The topic has been locked.

Delete highlight from page 6 years 6 months ago #12924

  • Davide
  • Davide's Avatar
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 814
  • Thank you received: 65
Hi,
you need to call page.ObjsStart(); before m_annot.RemoveFromPage();.
For more info check this : www.radaeepdf.com/documentation/javadocs...age.html#ObjsStart--

Document.CanSave() dipends on how you open the doc, it returns false if you open it in memory for example using OpenMem, in this case is opened in read only mode and you can't even add annots..
The following user(s) said Thank You: vlad91
The topic has been locked.

Delete highlight from page 6 years 6 months ago #12930

  • vlad91
  • vlad91's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 5
  • Thank you received: 0
I used OpenMem, that was causing my problems, hopefully it will be smooth sailing from now on. Cheers!
The topic has been locked.

Delete highlight from page 3 years 4 months ago #15355

  • razvar
  • razvar's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
Sorry to revamp this thread, but I'm having the same issue: I can't remove highlight annotations unless the file is loaded from disk and not from memory stream. The thing is that it works to add annotations while pdf loaded from memory stream as documented here: www.radaeepdf.com/support/knowledge-base?view=kb&kbartid=54 . But I can't remove them back once added (unless I re-reopen the document/recreate the objects, but that's not an option for a simple highlight removal to reload the entire document ).

Is there any other way around this? Since I can add them while loaded in memory I should be able to also remove them. But no way to remove them back (RemoveFromPage / removeAnnot just returns false and it's not removed unless pdf is loaded from disk storage). I've also tried using SetCache while document loaded from memory stream, but that doesn't help; as soon as document is opened from disk tho, removing annotation will work as it should.

Thanks.
The topic has been locked.

Delete highlight from page 3 years 4 months ago #15356

  • radaee
  • radaee's Avatar
  • Offline
  • Moderator
  • Moderator
  • Posts: 1123
  • Thank you received: 73
the PDF file will be always readonly, if using Document.OpenMem() open PDF file.

but, you can use Document.OpenStream() with com.radaee.util.PDFMemStream object to open PDF.
int this way, the PDF file can read/write, and also can save.
after Document.Save() invoked, the saved data can be got by PDFMemStream.get_data() and PDFMemStream.get_size();
The following user(s) said Thank You: razvar
Last edit: by radaee.
The topic has been locked.

Delete highlight from page 3 years 4 months ago #15357

  • razvar
  • razvar's Avatar
  • Offline
  • New Member
  • New Member
  • Posts: 15
  • Thank you received: 0
Thanks a lot! That helped a lot tracking this down. It was my fault, as I was already using/implementing PDFStream but forgot to return from writable override true, I was always returning false, thus marking the PDFStream as read only. So, just returning true instead of false on my PDFStream implementation, made it work as it should:
      //PDF Stream Interface
	@Override
	public boolean writeable()
	{
		return true; //return true here or else the annoations created with page.AddAnnotMarkup can't be removed with Annotation.RemoveFromPage() 
	}

Thanks again!
The topic has been locked.
  • Page:
  • 1
Powered by Kunena Forum