mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 10:08:06 +02:00
Use the link service for getting and setting page information
This removes the dependency on a `PDFViewer` instance from the find controller, which makes it more similar to other components and makes it easier to unit test with a mock link service. Finally, we remove the search capabilities from the SVG example since it doesn't work there because there is no separate text layer.
This commit is contained in:
parent
e293c12afc
commit
e0c811f2ed
5 changed files with 21 additions and 24 deletions
|
@ -31,7 +31,6 @@ var CMAP_URL = '../../node_modules/pdfjs-dist/cmaps/';
|
|||
var CMAP_PACKED = true;
|
||||
|
||||
var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
|
||||
var SEARCH_FOR = ''; // try 'Mozilla';
|
||||
|
||||
var container = document.getElementById('viewerContainer');
|
||||
|
||||
|
@ -46,19 +45,9 @@ var pdfViewer = new pdfjsViewer.PDFViewer({
|
|||
});
|
||||
pdfLinkService.setViewer(pdfViewer);
|
||||
|
||||
// (Optionally) enable find controller.
|
||||
var pdfFindController = new pdfjsViewer.PDFFindController({
|
||||
pdfViewer: pdfViewer,
|
||||
});
|
||||
pdfViewer.setFindController(pdfFindController);
|
||||
|
||||
container.addEventListener('pagesinit', function () {
|
||||
// We can use pdfViewer now, e.g. let's change default scale.
|
||||
pdfViewer.currentScaleValue = 'page-width';
|
||||
|
||||
if (SEARCH_FOR) { // We can try search for things
|
||||
pdfFindController.executeCommand('find', { query: SEARCH_FOR, });
|
||||
}
|
||||
});
|
||||
|
||||
// Loading document.
|
||||
|
@ -72,5 +61,4 @@ pdfjsLib.getDocument({
|
|||
pdfViewer.setDocument(pdfDocument);
|
||||
|
||||
pdfLinkService.setDocument(pdfDocument, null);
|
||||
pdfFindController.setDocument(pdfDocument);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue