How to locate annotations?
[Logo]
ICEsoft.org Forums: ICEfaces, ICEmobile, ICEpdf
[Search] Search   [Recent Topics] Recent Topics   [Groups] Home Page | www.icesoft.org  [Login] Login 
How to locate annotations?  XML
Forum Index -> ICEpdf General
Author Message
benge

Joined: 11/12/2011 08:07:50
Messages: 3
Offline


Hi,guys.I am new here. I didn't know if it is the optimum catagory for my question, but I believe you guys will help me.
I want to extract the text between the pages which I mark the annotation.
First, I think I should locate the annotation.Then, extract the text between the pages which I mark the annotation.

What should I do ?
I will Appreciate it, If you can give me some java pragram examples.
Thank you!
patrick.corless

Joined: 26/10/2004 00:00:00
Messages: 1150
Offline


You can iterate over pages in a document and get at the page annotations like this

Code:
final Object pagelock = new Object();
  Catalog catalog = document.getCatalog();
  for (int i = 0; i < document.getNumberOfPages(); i++) {
      Page page = catalog.getPageTree().getPage(i, pagelock);
      // iterate over annotations, look for the marker annotation
      List<Annotation> annotations =  page.getAnnotations();
      for (Annotation annotation: annotations){
           
      }
 
      catalog.getPageTree().releasePage(page, pagelock);
  } 


Getting the page text is a simple as calling
Code:
page.getText();
[Email]
amsmota

Joined: 01/11/2010 05:48:28
Messages: 64
Offline


Hmm, I noticed that I often don't do the

Code:
catalog.getPageTree().releasePage(page, pagelock);


What am I risking here?

BTW, I have a similar code to, giving a annotation, go to the page where that annotation is and select it (to be used on the Viewer), if needed please let me know.
patrick.corless

Joined: 26/10/2004 00:00:00
Messages: 1150
Offline


The pageLock variable as it is used by the memory manager to lock the resources around the page being processed. With out the lock the memory manager could might prematurely dispose resource associated the page being processed. This can result in unpredictable results such as missing text or annotations.

In a single threaded app the problem usually show up but in theory still possible. I would recommend you lock and unlock a page just to be sure.
[Email]
benge

Joined: 11/12/2011 08:07:50
Messages: 3
Offline


Thank you for your reply!
Is there a reference document? So I can understand usage of related JAVA API.
Thank you!

patrick.corless wrote:
You can iterate over pages in a document and get at the page annotations like this

Code:
final Object pagelock = new Object();
  Catalog catalog = document.getCatalog();
  for (int i = 0; i < document.getNumberOfPages(); i++) {
      Page page = catalog.getPageTree().getPage(i, pagelock);
      // iterate over annotations, look for the marker annotation
      List<Annotation> annotations =  page.getAnnotations();
      for (Annotation annotation: annotations){
           
      }
 
      catalog.getPageTree().releasePage(page, pagelock);
  } 


Getting the page text is a simple as calling
Code:
page.getText();
 
benge

Joined: 11/12/2011 08:07:50
Messages: 3
Offline


Is there any reference document about related JAVA API? Thank you.

amsmota wrote:
Hmm, I noticed that I often don't do the

Code:
catalog.getPageTree().releasePage(page, pagelock);


What am I risking here?

BTW, I have a similar code to, giving a annotation, go to the page where that annotation is and select it (to be used on the Viewer), if needed please let me know.
 
amsmota

Joined: 01/11/2010 05:48:28
Messages: 64
Offline


What do you mean? The Javadoc for the API's?

http://www.icepdf.org/docs/v4_0_0/core/javadocs/

http://www.icepdf.org/docs/v4_0_0/viewer/javadocs/
 
Forum Index -> ICEpdf General
Go to:   
Powered by JForum 2.1.7ice © JForum Team