Home  Products  Purchase  Downloads  Demos  Forums  Blogs  Ticket  Wiki  API  Corporate

com.aspose.pdf.kit
Class PdfSearcher

java.lang.Object
  extended bycom.aspose.pdf.kit.PdfSearcher

public class PdfSearcher
extends java.lang.Object

Represents a class to search text from pdf file.


Constructor Summary
PdfSearcher()
          The constructor of the PdfSearcher object.
 
Method Summary
 void bindPdf(java.io.InputStream inputStream)
          Binds a Pdf Stream for search.
 void bindPdf(java.lang.String inputFile)
          Binds a Pdf file for search.
 int getEndPage()
          Gets endPage value.
 java.util.Map getMatchText()
          Gets all match text points within the rectangle.
 int getStartPage()
          Gets startPage value.
 void searchTextInRectangle(java.awt.Rectangle rec, java.lang.String textToSearch)
          Searchs the location of the textToSearch within the rectangle from startPage to endPage.
 void searchTextInRectangle(java.awt.Rectangle rec, java.lang.String textToSearch, boolean isCaseSensitive)
          Searchs the location of the textToSearch within the rectangle from startPage to endPage.
 void setEndPage(int endPage)
          Sets endPage value.
 void setStartPage(int startPage)
          Sets startPage value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PdfSearcher

public PdfSearcher()
The constructor of the PdfSearcher object.

Method Detail

setStartPage

public void setStartPage(int startPage)
Sets startPage value.

Parameters:
startPage - start position which you want to search of the pdf file.

getStartPage

public int getStartPage()
Gets startPage value.

Returns:
start position which you want to search of the pdf file.

setEndPage

public void setEndPage(int endPage)
Sets endPage value.

Parameters:
endPage - end position which you want to search of the pdf file.

getEndPage

public int getEndPage()
Gets endPage value.

Returns:
end position which you want to search of the pdf file.

bindPdf

public void bindPdf(java.lang.String inputFile)
             throws java.io.FileNotFoundException
Binds a Pdf file for search.

Parameters:
inputFile - The pdf file to be searched.
Throws:
java.io.FileNotFoundException

bindPdf

public void bindPdf(java.io.InputStream inputStream)
Binds a Pdf Stream for search.

Parameters:
inputStream - The pdf Stream to be searched.
Throws:
java.io.FileNotFoundException

searchTextInRectangle

public void searchTextInRectangle(java.awt.Rectangle rec,
                                  java.lang.String textToSearch,
                                  boolean isCaseSensitive)
                           throws PdfViewerException,
                                  java.lang.Exception
Searchs the location of the textToSearch within the rectangle from startPage to endPage. The rectangle coordinate origin is the top left corner in pdf files, and its coordinate is (0,0). If you have not the license, this software can search the first matched text.

Parameters:
rec - java.awt.Rectangle the rectangle which extracted the texts. The coordinate origin is (0,0) which is the pdf file top left point. The rec.width is the extraction text width and the rec.height is the extraction text height.
textToSearch - String the text to search.
isCaseSensitive - boolean if a case sensitive comparison happens or not when searching.
Throws:
PdfViewerException
java.lang.Exception

searchTextInRectangle

public void searchTextInRectangle(java.awt.Rectangle rec,
                                  java.lang.String textToSearch)
                           throws PdfViewerException,
                                  java.lang.Exception
Searchs the location of the textToSearch within the rectangle from startPage to endPage. The rectangle coordinate origin is the top left corner in pdf files, and its coordinate is (0,0). If you have not the license, this software can search the first matched text.

Parameters:
rec - java.awt.Rectangle the rectangle which extracted the texts. The coordinate origin is (0,0) which is the pdf file top left point. The rec.width is the extraction text width and the rec.height is the extraction text height.
textToSearch - String the text to search.
Throws:
PdfViewerException
java.lang.Exception

getMatchText

public java.util.Map getMatchText()
                           throws java.lang.Exception
Gets all match text points within the rectangle. The first Object in the return Map is the page number in searching ,and the second Object is the match points.

Returns:
java.util.Map the match text points within the rectangle.
Throws:
java.lang.Exception