search for specific words inside a pdf document in Xcode

RB24 is my pdf doc. Im using a "view" inside my View Controller and the Class for that view is a PDFView.

When I see the pdf on my app, I can't do a search inside the pdf document. How can I achieve that?

When you open a pdf in your iPhone, iPhone uses an app that lets you do search and annotations on the pdf. Is there any way to do that for your app ?

Any help will be greatly appreciated !

UIKit import PDFKit

class ViewControllerRB: UIViewController {

@IBOutlet weak var PDFViewRB: PDFView! override func viewDidLoad() { super.viewDidLoad()

    let url = Bundle.main.url(forResource: "RB24", withExtension: "pdf")
    

    
    if let pdfDocument = PDFDocument(url: url!) {
        
        PDFViewRB.autoScales = true
        PDFViewRB.displayMode = .singlePageContinuous
        PDFViewRB.displayDirection = .vertical
        PDFViewRB.document = pdfDocument

Replies

Have you read the documentation on the PDFDocument class, for instance the findString(_:withOptions:) method?

  • I have, and understand zero, I m a very very beginner. The app if working great, I just need to find a way to be able to apply a search function to the user can search for a word within the pdf doc, exactly as what an. iPhone does when you open up a pdf file

Add a Comment