-
Notifications
You must be signed in to change notification settings - Fork 10.2k
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
Requests/Improvements for web/pdf_find_bar.js #10629
Comments
In general, please keep the following in mind (quoting from https://mozilla.github.io/pdf.js/getting_started/):
Something along these lines were rejected previously, please refer to #5803 (comment) in particular.
That would cause issues with the Firefox version of the default viewer (which is the primary reason for this library existing in the first place), please see Lines 2000 to 2018 in e1b01a6
Not having
It's not clear what either of this actually means.
This would be a more general issue, not really relevant/fixable in individual files, which is tracked in #10317. |
Closing as answered since I also don't see anything that we can improve here that should be part of the library. |
Thank you for your responses and for your help. Just to understand, can PDFFindbar, PDFFindController, PDFViewer, and PDFLinkService all be referenced from PDFViewerApplication after importing pdf.js/web/app.js? Also, does pdf.js v2.0.943 include app.js as well as the eventBus changes you added last Fall? Have a good evening, Jabari |
Yes, the version 2.0 release contains all changes after the find controller refactoring. You may also want to read through #10120 since that contains information about what we improved to decouple the the find controller and find bar so it's easier to integrate for third-party applications. |
Great. I will explore the version 2.0 release and read through #10120 to see how we can use the find bar without modifying the find bar source code. Thank you again for your help. I'll let you know if I have questions |
Hi, this is in reference to #10120
First and foremost, I want to thank you for all the effort you've put into making pdf.js a great solution. The pdf viewer, the pdf highlighting, and more perform very well and take only a few lines of code to integrate and implement - you've provided a great service. What I am here for is to see how I can help you provide even greater service
I am using pdf_find_bar.js for a third-party integration. In order to get it working, I had to create a modified version of your pdf_find_bar.js file
I would like to work with you to add a few changes/improvements to pdf_find_bar.js so that my team can work with pdf_find_bar.js out of the box. I appreciate your time, input, and suggestions
Attach (recommended) or Link to PDF file here: http://www.pdf995.com/samples/pdf.pdf
Configuration:
Steps to reproduce the problem:
(notice that there is no toggleButton in the options below - this is intentional because we don't use the toggleButton)
const options = { bar: document.getElementById('findbar'), findField: document.getElementById('findInput'), highlightAllCheckbox: document.getElementById('findHighlightAll'), caseSensitiveCheckbox: document.getElementById('findMatchCase'), entireWordCheckbox: document.getElementById('findEntireWord'), findMsg: document.getElementById('findMsg'), findResultsCount: document.getElementById('findResultsCount'), findPreviousButton: document.getElementById('findPrevious'), findNextButton: document.getElementById('findNext'), findController: pdfFindController, eventBus: pdfLinkService.eventBus }
3. Reference web/pdf_find_bar.js and create new instance
var pdfFindBar = new PDFFindBar(options, pdfLinkService.l10n);
4. Load and set the document
What is the expected behavior? (add screenshot)
The expected behavior is that the document search should work as in the pdfjs online demo
What went wrong? (add screenshot)
No matches are found
Here are my suggested changes/improvements in the pdf_find_bar.js file:
A. (line 58) set the script findController to the passed-in findController (options.findController):
(line 33)
var _pdf_find_controller = null;
(line 58)
_pdf_find_controller = pdfFindController;
B. (line 134) update the dispatchEvent() function to call the findController's executeCommand() function:
C. (line 35) add _findState object and update references to findState (I know this doesn't make sense, but the findController's findState object was missing):
D. (line 48) add MATCHES_COUNT_LIMIT (this was also missing):
const MATCHES_COUNT_LIMIT = 1000;
(line 295) Optionally add
default export PDFFindBar
for ES6 compatibilityI commented out the following lines:
(lines 24-31):
(lines 55-56):
I know I don't have all of the answers and I may have done some things incorrectly. What I did above was done to get the pdfFindBar working for my team, based on the pdfjs documentation available and from looking through the pdfjs source code of working examples. The solution works. Now, I'd like to work with you to make this a better solution for all of us
Have a great day,
Jabari
The text was updated successfully, but these errors were encountered: