Fix for broken search functionality when showPage=false #391
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prologue
This is my first fork/PR of an open source porject, so please point out errors if found, thanks!
Issues getting fixed by this PR
General Overview
While working on an integration in a current web-frontend project I noticed, that the search functionality was not working when displaying only a single page (with showAll = false).
I saw that the viewer used a PDFPageView to display a single page and a PDFViewer for all pages. By this, the content of the PDF could only be searched, when the PDFViewer was displaying all pages.
This fix uses the PDFSinglePageViewer (https://github.com/mozilla/pdf.js/blob/master/web/pdf_single_page_viewer.js) instead of a PDFPageView, which causes a lot of changes internally, thus the many changes in this PR.
Most important changes
Please note the changes to the following methods:
setupViewer()
: Removed in favor ofsetupMultiPageViewer()
andsetupSinglePageViewer()
renderPage()
,removeAllChildNodes()
: Removed, because no longer neededupdate()
,render()
,updateSize()
: All these methods and the methods called by them lost the check to showAll, since now they don't care anymore if there is a single page or multiple (by just callingcurrentViewer
). PDFSinglePageViewer handles everything elseresetPdfDocument()
: New important method used to show/hide the active/inactive viewer by callingsetDocument()
with either null (to hide the viewer) or the pdf (to show it)