| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 11/12/2011 09:30:46
|
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!
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 12/12/2011 07:04:50
|
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:
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 12/12/2011 08:33:28
|
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.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 12/12/2011 08:47:50
|
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.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 15/12/2011 23:19:11
|
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:
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 15/12/2011 23:38:33
|
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.
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 16/12/2011 03:19:15
|
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/
|
|
|
 |
|
|