public class PDFTextSearch
extends java.lang.Object
PDFTextSearch
represents a search object to search a PDF
page text.
The PDFTextSearch
defines methods to search characters in a page
and other operations to get the search result.
It can be constructed by the following way.
Example:
PDFTextPage textPage = PDFTextPage.create(pdfPage); PDFTextSearch textSearch = textPage.startSearch("Foxit", PDFTextSearch.FLAG_MATCHCASE, 0)
PDFTextPage
,
PDFTextSelection
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_CONSECUTIVE
Whether matching consecutively (for example, "CC" will match twice in
"CCC").
|
static int |
FLAG_MATCHCASE
Whether matching case.
|
static int |
FLAG_MATCHWHOLEWORD
Whether matching whole word.
|
Constructor and Description |
---|
PDFTextSearch(PDFTextPage textpage)
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
. |
Modifier and Type | Method and Description |
---|---|
boolean |
findNext()
Search in the direction from page start to end.
|
boolean |
findPrev()
Search in the direction from page end to start.
|
long |
getHandle()
Get text search handle.
|
PDFTextSelection |
getSelection()
Get a
PDFTextSelection from a text search when a match is
found. |
void |
release()
Clear all resources allocated for a
PDFTextSearch object. |
boolean |
startSearch(java.lang.String text,
int flags,
int startPostion)
Deprecated.
Current function will be deprecated in future. So, not recommend to use current function any more.
Instead, please use
. |
public static final int FLAG_MATCHCASE
public static final int FLAG_MATCHWHOLEWORD
public static final int FLAG_CONSECUTIVE
public PDFTextSearch(PDFTextPage textpage)
PDFTextPage.startSearch(String, int, int)
.PDFTextSearch
object with the specified
PDFTextPage
object.textpage
- The specified PDFTextPage
object.PDFTextPage
public long getHandle()
public boolean startSearch(java.lang.String text, int flags, int startPostion) throws PDFException
PDFTextPage.startSearch(String, int, int)
.
This function starts a search process. Then function
or findNext()
should be called to find the first matched pattern.findPrev()
This function must be called before any other search related functions.
text
- The string to be found.flags
- Indicate the find options. 0 means no special finding options.
And it can be one or combination of the followings:
startPostion
- A zero-based index specifying the character from which the
search will start. Range: from -1 to (charcount-1).
-1 means from the end of the page. charcount
is
returned by function PDFTextPage.countChars()
in PDFTextPage
.true
if started the search process successfully,
else return false
for any errors.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFTextPage
public void release() throws PDFException
PDFTextSearch
object.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean findNext() throws PDFException
boolean value that indicates whether a match is found or not.
PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public boolean findPrev() throws PDFException
boolean
value indicates whether a match is found
or not.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
public PDFTextSelection getSelection() throws PDFException
PDFTextSelection
from a text search when a match is
found.PDFTextSelection
object to receive a new PDF text
selection handle if successful.PDFTextSelection.release()
.PDFException
- For more exception information please see definitions
PDFException.ERRCODE_XXX
.PDFException
,
PDFTextSelection