Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Purchase "Search functionality" feature possible? #179

Closed
GSORF opened this issue Mar 22, 2022 · 9 comments
Closed

Purchase "Search functionality" feature possible? #179

GSORF opened this issue Mar 22, 2022 · 9 comments

Comments

@GSORF
Copy link

GSORF commented Mar 22, 2022

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!

@GSORF
Copy link
Author

GSORF commented Jul 20, 2022

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:

  1. Fork this repository
  2. Apply the pull request from Taron133:SearchText_iOS
  3. 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)
  4. Inside the app: After loading a pdf file into the viewer, loop through each page and extract the document string using "getStringAt(page_id)"
  5. 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

@dupuchba
Copy link

dupuchba commented Oct 4, 2022

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 !

@mirkancal
Copy link

Screen.Recording.2023-03-29.at.10.42.23.mov

I've added for iOS, let me know what you guys think @endigo
mirkancal@49638d9

@GSORF
Copy link
Author

GSORF commented Mar 29, 2023

Thank you @mirkancal for your great work! This looks awesome.
And thank you, @dupuchba for your detailed feedback on this idea.

Due to time restrictions I had to move from flutter_pdfview to syncfusion_pdf (https://pub.dev/packages/syncfusion_flutter_pdf). I will therefore close this issue.

Kind regards,
Adam

@GSORF GSORF closed this as completed Mar 29, 2023
@mvukojicic
Copy link

@mirkancal Hey bro, nice work out there, did you by any chance make a solution to jump to a specific page when searching the text?

@mirkancal
Copy link

mirkancal commented Sep 27, 2023

@mvukojicic It's jumping to page but when there are lot of results from the same search keywords, it's pretty slow and freezes. I need to convert search results to stream or something. Also I couldn't find anything for Android.

That's swift version, code is easier to understand alhappler/alh_pdf_view#38

@mvukojicic
Copy link

@mirkancal Can you please point me to the part of the code and logic for jumping to searched words?

@mirkancal
Copy link

mirkancal commented Sep 27, 2023

@mvukojicic it's pdfView.go swift and goToPage in objc.

Line highlighted URLs:
mirkancal/alh_pdf_view@cf2d3a6#diff-1e42e7adbd1ae9be1a09a5f2c6865f0147bd8a042d7428db83a0573f769e783bR338-R343

mirkancal@49638d9#diff-494acf6b42388364aaee89f58f98b07e7daa1fe9a20eef4b723553b8d216baefR304-R311

@mvukojicic
Copy link

@mirkancal bro you are the king, thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants