flutter_pdfview
flutter_pdfview copied to clipboard
Purchase "Search functionality" feature possible?
Hi @endigo,
Thank you for the awesome flutter plugin, it works like a charm in my iOS simulator (couldn't test it on a real device yet, hope I will not have the same issue like a few other users).
I am currently developing an app for a client and presented him the first prototype draft which uses your PDF API. The client asked me if it is possible to search for keywords in the pdf view so that these get highlighted (similar to how it works in Adobe Acrobat Reader when you press "CTRL + F"). I see that this feature is on your Future Plans list.
My question is: In case I can acquire a bit more funding from my client, is it possible to fund a specific feature by buying you "several coffees"? I would love to support your work financially and consequently improve the quality for everyone else using it. In this early phase I just want to know if this is possible at all.
Thanks for your answer in advance and kind regards!
Unfortunately there is no answer to my question since three months. Therefore, I have started to implement the functionality myself. It is not perfect yet, but at least one can now search inside a pdf document.
In case anyone is in the same situation: What I did is the following:
- Fork this repository
- Apply the pull request from Taron133:SearchText_iOS
- In your flutter project: Do not add "flutter_pdf" from the official source but use your own git repository (that was actually the key to the implementation! I was not aware of this method before)
- Inside the app: After loading a pdf file into the viewer, loop through each page and extract the document string using "getStringAt(page_id)"
- In your search function: Compare the query string with the document string and store your matches. Then display them to the user (I am currently merely displaying the page number and a substring where the query string was found. Users can jump to the page by clicking on the search result)
This is not optimal yet, but at least a beginning. A big "thank you" goes to @Taron133 for implementing the string extraction feature. Highlighting the found text in the PDFViewer would be nice now, which - to my understanding - is not yet implemented.
Reading the documentation of PDFKit (iOS only) though, it appears to be possible to add this, compare https://www.pdftron.com/blog/ios/how-to-add-annotations-using-swift-and-pdfkit/
Since I have never worked with the swift programming language I will need some time to get my head around this, but it doesnt seem to be very difficult. If I will manage to implement highlighting, I will post my solution here as well.
Kind regards, Adam
Working with PDF is hard, if you look at the AppStore, PDF applications are often on the top most downloaded apps. In this plugin case, it creates a UiKitView which is still alpha on Flutter. Yes PDFKit provides by default search but it does not guarantees if it would work properly on UiKitView.
There is an other option to build PDF which is to render them via Flutters Texture layer, but then it's like if you draw images for each pages (no search as far as I can tell).
I think best dev XP would be to develop a renderer in pure Dart but it would literally take years (full-time). With my co-worker we've been there working with PDFs and the spec is just too big. That's basically why there are still proprietary APIs in this field. Anyway if you need high quality PDF renderer with the ability to customise everything, there might be some lib out there but I doubt it, otherwise you can try to help like you did !