Class Highlights
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:
page: the number of the page this Highlight is on; position: the start position (text offset) of this Highlight; length: the length of this Highlight.
Possible use case scenarios for Highlights include:
- Load a Highlight file (in XML format) and highlight the corresponding texts in the viewer (e.g., if the viewer is implemented using PDFViewCtrl, it can be achieved simply by calling PDFViewCtrl::SelectByHighlights() method);
- Save the Highlight information (e.g., constructed by the TextSearch class) to an XML file for external uses.
- 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.
Inheritance
Implements
Inherited Members
Namespace: pdftron.PDF
Assembly: PDFNetAndroid.dll
Syntax
public class Highlights : IDisposable
Remarks
For a sample code, please take a look at the TextSearchTest sample project.
Constructors
Highlights()
Creates a default Highlights
object
Declaration
public Highlights()
Highlights(Highlights)
Creates a Highlights from a given object
Declaration
public Highlights(Highlights hlts)
Parameters
Type | Name | Description |
---|---|---|
Highlights | hlts | a given |
Methods
Add(Highlights)
Add extra Highlight information into the class.
Declaration
public void Add(Highlights hlts)
Parameters
Type | Name | Description |
---|---|---|
Highlights | hlts | the Highlights of which the Highlight information is to be added. |
Begin(PDFDoc)
Rewind the internal pointer to the first highlight.
Declaration
public void Begin(PDFDoc doc)
Parameters
Type | Name | Description |
---|---|---|
PDFDoc | doc | the PDF document to which the highlights correspond. |
Remarks
the PDF document can be a dummy document unless getCurrentQuads() is to be called.
Clear()
Clear the current Highlight information in the class.
Declaration
public void Clear()
Destroy()
Declaration
public void Destroy()
Dispose()
Declaration
public void Dispose()
Dispose(Boolean)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing |
Finalize()
Releases all resources used by the Highlights
Declaration
protected void Finalize()
GetCurrentPageNumber()
Get the page number of the current highlight.
Declaration
public int GetCurrentPageNumber()
Returns
Type | Description |
---|---|
System.Int32 | the current page number |
GetCurrentQuads()
Get the corresponding quadrangles of the current highlight.
Declaration
public double[] GetCurrentQuads()
Returns
Type | Description |
---|---|
System.Double[] | the output quadrangles. Each quadrangle has eight doubles (x1, y1), (x2, y2), (x3, y3), (x4, y4) denoting the four vertices in counter-clockwise order. |
Remarks
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.
GetCurrentTextRange()
Get a TextRange
object that represents the current highlight.
Declaration
public TextRange GetCurrentTextRange()
Returns
Type | Description |
---|---|
TextRange | the current text range |
HasNext()
Query if there is any subsequent highlight after the current highlight.
Declaration
public bool HasNext()
Returns
Type | Description |
---|---|
System.Boolean | true, if successful |
Load(String)
Load the Highlight information from a file. Note that the pre-existing Highlight information is discarded.
Declaration
public void Load(string file_name)
Parameters
Type | Name | Description |
---|---|---|
System.String | file_name | the name of the file to load from. |
Next()
Move the current highlight to the next highlight.
Declaration
public void Next()
Save(String)
Save the current Highlight information in the class to a file.
Declaration
public void Save(string file_name)
Parameters
Type | Name | Description |
---|---|---|
System.String | file_name | the name of the file to save to. |
SaveToString()
Save the current Highlight information in the class to an XML string.
Declaration
public string SaveToString()
Returns
Type | Description |
---|---|
System.String | the highlight XML file contents as a string |