1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Use RequireJS in the viewer, examples and tests.

This commit is contained in:
Yury Delendik 2015-12-16 15:03:06 -06:00
parent 05b9d3730a
commit 85e95d34ed
17 changed files with 201 additions and 331 deletions

View file

@ -1,8 +1,3 @@
//
// See README for overview
//
'use strict';
// Parse query string to extract some parameters (it can fail for some input)
@ -14,10 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
var scale = +queryParams.scale || 1.5;
//
// Fetch the PDF document from the URL using promises
//
PDFJS.getDocument(url).then(function(pdf) {
function renderDocument(pdf) {
var numPages = pdf.numPages;
// Using promise to fetch the page
@ -53,4 +45,14 @@ PDFJS.getDocument(url).then(function(pdf) {
});
}.bind(null, i, anchor));
}
}
// In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api', 'pdfjs/display/svg'], function (api, svg) {
// In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js';
// Fetch the PDF document from the URL using promises.
api.getDocument(url).then(renderDocument);
});