Some test text!

keyboard_arrow_down

Get started

keyboard_arrow_down

FAQ

keyboard_arrow_down

Document viewer

keyboard_arrow_down

Tools UI Library

keyboard_arrow_down

Document viewer components

keyboard_arrow_down

Conversion

keyboard_arrow_down

Parsing and extraction

keyboard_arrow_down

Digital signatures

keyboard_arrow_down

Search

keyboard_arrow_down

Advanced customization

keyboard_arrow_down

Advanced topics

keyboard_arrow_down

Other frameworks

keyboard_arrow_down

Reference

keyboard_arrow_down

PDF Processing API

Text search

In this document
chevron_rightShow/hide the Find Text toolbar
chevron_rightHighlight search results
chevron_rightThe Find Text Toolbar Delegate

The FindTextToolbar class allows the user to enter and search text in a document. Search results are automatically highlighted in the document and floating buttons allow searching forward or backward through the document. The core find text toolbar functionality is provided by the PTPDFViewCtrl's text search methods.

The find text toolbar is part of the Tools library, so make sure you have added the Tools library to your project.

linkShow/hide the Find Text toolbar

To create and set up a Find Text toolbar, supply a PTPDFViewCtrl instance to the FindTextToolbar designated initializer and add the toolbar to your view hierarchy:

When the find text toolbar is shown, the searchBarBecomeFirstResponder method should be called to focus the search bar and show the keyboard.

linkHighlight search results

In order for search results to be highlighted on the page, the pdfViewCtrl:textSearchResult: method of the PTPDFViewCtrlDelegate protocol must be implemented by the adopting class, usually the containing view controller:

linkThe Find Text Toolbar Delegate

The FindTextToolbarDelegate protocol allows the adopting class (usually the containing view controller, as in this guide) to be notified of find text toolbar events. Since this protocol also conforms to the UIToolbarDelegate protocol, the find text toolbar's delegate can implement the positionForBar: method to indicate the toolbar position: