1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

[api-major] Completely remove the global PDFJS object

This commit is contained in:
Jonas Jenwald 2018-02-17 23:51:24 +01:00
parent 4b4fcecf70
commit b8606abbc1
18 changed files with 323 additions and 426 deletions

View file

@ -15,14 +15,14 @@
'use strict';
if (!PDFJS.PDFPageView || !PDFJS.getDocument) {
if (!pdfjsDistBuildPdf.getDocument || !pdfjsDistWebPdfViewer.PDFPageView) {
alert('Please build the pdfjs-dist library using\n' +
' `gulp dist-install`');
}
// The workerSrc property shall be specified.
//
PDFJS.GlobalWorkerOptions.workerSrc =
pdfjsDistBuildPdf.GlobalWorkerOptions.workerSrc =
'../../node_modules/pdfjs-dist/build/pdf.worker.js';
// Some PDFs need external cmaps.
@ -37,7 +37,7 @@ var SCALE = 1.0;
var container = document.getElementById('pageContainer');
// Loading document.
PDFJS.getDocument({
pdfjsDistBuildPdf.getDocument({
url: DEFAULT_URL,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
@ -45,14 +45,14 @@ PDFJS.getDocument({
// Document loaded, retrieving the page.
return pdfDocument.getPage(PAGE_TO_VIEW).then(function (pdfPage) {
// Creating the page view with default parameters.
var pdfPageView = new PDFJS.PDFPageView({
var pdfPageView = new pdfjsDistWebPdfViewer.PDFPageView({
container: container,
id: PAGE_TO_VIEW,
scale: SCALE,
defaultViewport: pdfPage.getViewport(SCALE),
// We can enable text/annotations layers, if needed
textLayerFactory: new PDFJS.DefaultTextLayerFactory(),
annotationLayerFactory: new PDFJS.DefaultAnnotationLayerFactory()
textLayerFactory: new pdfjsDistWebPdfViewer.DefaultTextLayerFactory(),
annotationLayerFactory: new pdfjsDistWebPdfViewer.DefaultAnnotationLayerFactory(),
});
// Associates the actual page with the view, and drawing it
pdfPageView.setPdfPage(pdfPage);