public class Highlights
extends java.lang.Object
Highlights
is used to store the necessary information and perform certain
tasks in accordance with Adobe's Highlight standard, whose details can be
found at
http://partners.adobe.com/public/developer/en/pdf/HighlightFileFormat.pdf.
In a nutshell, the Highlights
class maintains a set of highlights.
Each highlight contains three pieces of information:
Possible use case scenarios for Highlights include:
TextSearch
class) to an XML file for external uses.
Note:
- The Highlights
class does not maintain the corresponding PDF document for
its highlights. It is the user's responsibility to match them up.
- The Highlights
class ensures that each highlight it maintains is
unique (no two highlights have the same page, position and length values).
- The current implementation of Highlights
only supports the 'characters'
encoding for 'units' as described in the format; the 'words' encoding is
not supported at this point.
For a sample code, please take a look at the TextSearch sample project.
Constructor and Description |
---|
Highlights()
Instantiate default highlights.
|
Highlights(long other_impl) |
Modifier and Type | Method and Description |
---|---|
void |
add(Highlights hlts)
Add extra Highlight information into the class.
|
void |
begin(PDFDoc doc)
Rewind the internal pointer to the first highlight.
|
void |
clear()
Clear the current Highlight information in the class.
|
void |
destroy()
Frees the native memory of the object.
|
int |
getCurrentPageNumber()
Get the page number of the current highlight.
|
double[] |
getCurrentQuads()
Get the corresponding quadrangles of the current highlight.
|
boolean |
hasNext()
Query if there is any subsequent highlight after the current highlight.
|
void |
load(java.lang.String file_name)
Load the Highlight information from a file.
|
void |
next()
Move the current highlight to the next highlight.
|
void |
save(java.lang.String file_name)
Save the current Highlight information in the class to a file.
|
public Highlights()
public Highlights(long other_impl)
public void destroy()
public void load(java.lang.String file_name)
file_name
- the name of the file to load from.public void save(java.lang.String file_name)
file_name
- the name of the file to save to.public void add(Highlights hlts)
hlts
- the Highlights of which the Highlight information is to be
added.public void clear()
public void begin(PDFDoc doc)
Note: the PDF document can be a dummy document unless getCurrentQuads()
is to be called.
doc
- the PDF document to which the highlights correspond.public boolean hasNext()
true
, if there is subsequent highlightpublic void next()
public int getCurrentPageNumber()
public double[] getCurrentQuads()
Note: since a highlight may correspond to multiple quadrangles, e.g., when it crosses a line, the number of resulting quadrangles may be larger than 1.