Browse Source

Add a `PDFLinkService` instance to the "simpleviewer" component example

Jonas Jenwald 10 years ago
parent
commit
297f760dce
  1. 15
      examples/components/simpleviewer.js

15
examples/components/simpleviewer.js

@ -34,17 +34,26 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) { @@ -34,17 +34,26 @@ if (!PDFJS.PDFViewer || !PDFJS.getDocument) {
var DEFAULT_URL = '../../web/compressed.tracemonkey-pldi-09.pdf';
var container = document.getElementById('viewerContainer');
// (Optionally) enable hyperlinks within PDF files.
var pdfLinkService = new PDFJS.PDFLinkService();
var pdfViewer = new PDFJS.PDFViewer({
container: container
container: container,
linkService: pdfLinkService,
});
pdfLinkService.setViewer(pdfViewer);
container.addEventListener('pagesinit', function () {
// we can use pdfViewer now, e.g. let's change default scale.
// We can use pdfViewer now, e.g. let's change default scale.
pdfViewer.currentScaleValue = 'page-width';
});
// Loading document.
PDFJS.getDocument(DEFAULT_URL).then(function (pdfDocument) {
// Document loaded, specifying document for the viewer.
// Document loaded, specifying document for the viewer and
// the (optional) linkService.
pdfViewer.setDocument(pdfDocument);
pdfLinkService.setDocument(pdfDocument, null);
});

Loading…
Cancel
Save