There are two parts to text searching. First is the UI component that is presented to the user. Second is an API guide to perform the text search functionality.
The PTTextSearchViewController
class allows the user to enter and search text in a document. Search results are automatically highlighted in the document and a toolbar with navigation buttons allows searching forward or backward through the document. The core text search functionality is provided by the PTPDFViewCtrl
's text search methods.
The search view controller is part of the Tools library, so make sure you have added the Tools library to your project.
To create and set up a text search view controller, supply a PTPDFViewCtrl
instance to the PTTextSearchViewController
designated initializer:
The PTTextSearchViewController
also presents the search results in a UITableView
for fast and easy navigation. Selecting any result in the table view will immediately navigate to that result and highlight it.
The PTTextSearchViewController
interface also allows the user to refine the search to be case-sensitive, or to match whole words only:
The PTTextSearchViewControllerDelegate
protocol allows the adopting class (usually the containing view controller, as in this guide) to be notified when the view controller has been dismissed. This can be used to show or hide other content as appropriate.
To search for text in a PDF using regular expression and then apply a link annotation on the highlighted result.
In this example, we add a link annotation but any other types of annotations can be applied here such as redaction annotations in the case of a search and redact workflow.
Search PDF files for text
Full code sample which shows how to use TextSearch to search text on PDF pages using regular expressions.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales