Now I have found a solution!
var container = document.getElementById('viewerContainer'); var viewer = document.getElementById('viewer'); var pdfViewer = new PDFViewer({ container: container, viewer: viewer }); $scope.pdfFindController = new PDFFindController({ pdfViewer: pdfViewer ); pdfViewer.setFindController($scope.pdfFindController); container.addEventListener('pagesinit', function () { pdfViewer.currentScaleValue = 'page-width'; }); PDFJS.getDocument(MY_PATH_TO_THE_PDF).then(function (pdfDocument) { pdfViewer.setDocument(pdfDocument); });
Search for terms:
$scope.pdfFindController.executeCommand('find', { caseSensitive: false, findPrevious: undefined, highlightAll: true, phraseSearch: true, query: "myQuery" });
And I had to import viewer.js.
The code I posted in the question is no longer needed. PDFViewer provides a PDF file.
source share