Exposes all functional members via lib exports and use them in viewer.

This commit is contained in:
Yury Delendik 2016-03-28 16:44:27 -05:00
parent 1d12aed5ca
commit 1e3e14e6b2
25 changed files with 174 additions and 102 deletions

View File

@ -140,9 +140,9 @@ function renderPage(div, pdf, pageNumber, callback) {
// In production, the bundled pdf.js shall be used instead of RequireJS. // In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}}); require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api'], function (api) { require(['pdfjs/display/api', 'pdfjs/display/global'], function (api, global) {
// In production, change this to point to the built `pdf.worker.js` file. // In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js'; global.PDFJS.workerSrc = '../../src/worker_loader.js';
// Fetch the PDF document from the URL using promises. // Fetch the PDF document from the URL using promises.
api.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) { api.getDocument(pdfWithFormsPath).then(function getPdfForm(pdf) {

View File

@ -2,9 +2,9 @@
// In production, the bundled pdf.js shall be used instead of RequireJS. // In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}}); require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api'], function (api) { require(['pdfjs/display/api', 'pdfjs/display/global'], function (api, global) {
// In production, change this to point to the built `pdf.worker.js` file. // In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js'; global.PDFJS.workerSrc = '../../src/worker_loader.js';
// Fetch the PDF document from the URL using promises. // Fetch the PDF document from the URL using promises.
api.getDocument('helloworld.pdf').then(function (pdf) { api.getDocument('helloworld.pdf').then(function (pdf) {

View File

@ -13,7 +13,7 @@ var fs = require('fs');
global.DOMParser = require('./domparsermock.js').DOMParserMock; global.DOMParser = require('./domparsermock.js').DOMParserMock;
// Run `gulp dist` to generate 'pdfjs-dist' npm package files. // Run `gulp dist` to generate 'pdfjs-dist' npm package files.
require('../../build/dist'); var pdfjsLib = require('../../build/dist');
// Loading file from file system into typed array // Loading file from file system into typed array
var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf'; var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf';
@ -21,7 +21,7 @@ var data = new Uint8Array(fs.readFileSync(pdfPath));
// Will be using promises to load document, pages and misc data instead of // Will be using promises to load document, pages and misc data instead of
// callback. // callback.
PDFJS.getDocument(data).then(function (doc) { pdfjsLib.getDocument(data).then(function (doc) {
var numPages = doc.numPages; var numPages = doc.numPages;
console.log('# Document Loaded'); console.log('# Document Loaded');
console.log('Number of Pages: ' + numPages); console.log('Number of Pages: ' + numPages);

View File

@ -11,7 +11,7 @@ var fs = require('fs');
require('./domstubs.js'); require('./domstubs.js');
// Run `gulp dist` to generate 'pdfjs-dist' npm package files. // Run `gulp dist` to generate 'pdfjs-dist' npm package files.
require('../../build/dist'); var pdfjsLib = require('../../build/dist');
// Loading file from file system into typed array // Loading file from file system into typed array
var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf'; var pdfPath = process.argv[2] || '../../web/compressed.tracemonkey-pldi-09.pdf';
@ -44,7 +44,7 @@ function getFileNameFromPath(path) {
// Will be using promises to load document, pages and misc data instead of // Will be using promises to load document, pages and misc data instead of
// callback. // callback.
PDFJS.getDocument(data).then(function (doc) { pdfjsLib.getDocument(data).then(function (doc) {
var numPages = doc.numPages; var numPages = doc.numPages;
console.log('# Document Loaded'); console.log('# Document Loaded');
console.log('Number of Pages: ' + numPages); console.log('Number of Pages: ' + numPages);
@ -59,7 +59,7 @@ PDFJS.getDocument(data).then(function (doc) {
console.log(); console.log();
return page.getOperatorList().then(function (opList) { return page.getOperatorList().then(function (opList) {
var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs); var svgGfx = new pdfjsLib.SVGGraphics(page.commonObjs, page.objs);
svgGfx.embedFonts = true; svgGfx.embedFonts = true;
return svgGfx.getSVG(opList, viewport).then(function (svg) { return svgGfx.getSVG(opList, viewport).then(function (svg) {
var svgDump = svg.toString(); var svgDump = svg.toString();

View File

@ -9,7 +9,7 @@ var queryParams = query ? JSON.parse('{' + query.split('&').map(function (a) {
var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf'; var url = queryParams.file || '../../test/pdfs/liveprogramming.pdf';
var scale = +queryParams.scale || 1.5; var scale = +queryParams.scale || 1.5;
function renderDocument(pdf) { function renderDocument(pdf, svgLib) {
var numPages = pdf.numPages; var numPages = pdf.numPages;
// Using promise to fetch the page // Using promise to fetch the page
@ -37,7 +37,7 @@ function renderDocument(pdf) {
anchor.appendChild(container); anchor.appendChild(container);
return page.getOperatorList().then(function (opList) { return page.getOperatorList().then(function (opList) {
var svgGfx = new PDFJS.SVGGraphics(page.commonObjs, page.objs); var svgGfx = new svgLib.SVGGraphics(page.commonObjs, page.objs);
return svgGfx.getSVG(opList, viewport).then(function (svg) { return svgGfx.getSVG(opList, viewport).then(function (svg) {
container.appendChild(svg); container.appendChild(svg);
}); });
@ -49,14 +49,17 @@ function renderDocument(pdf) {
// In production, the bundled pdf.js shall be used instead of RequireJS. // In production, the bundled pdf.js shall be used instead of RequireJS.
require.config({paths: {'pdfjs': '../../src'}}); require.config({paths: {'pdfjs': '../../src'}});
require(['pdfjs/display/api', 'pdfjs/display/svg'], function (api, svg) { require(['pdfjs/display/api', 'pdfjs/display/svg', 'pdfjs/display/global'],
function (api, svg, global) {
// In production, change this to point to the built `pdf.worker.js` file. // In production, change this to point to the built `pdf.worker.js` file.
PDFJS.workerSrc = '../../src/worker_loader.js'; global.PDFJS.workerSrc = '../../src/worker_loader.js';
// In production, change this to point to where the cMaps are placed. // In production, change this to point to where the cMaps are placed.
PDFJS.cMapUrl = '../../external/bcmaps/'; global.PDFJS.cMapUrl = '../../external/bcmaps/';
PDFJS.cMapPacked = true; global.PDFJS.cMapPacked = true;
// Fetch the PDF document from the URL using promises. // Fetch the PDF document from the URL using promises.
api.getDocument(url).then(renderDocument); api.getDocument(url).then(function (doc) {
renderDocument(doc, svg);
});
}); });

View File

@ -3,7 +3,7 @@
// Hello world example for webpack. // Hello world example for webpack.
require('pdfjs-dist'); var pdfjsLib = require('pdfjs-dist');
var pdfPath = '../helloworld/helloworld.pdf'; var pdfPath = '../helloworld/helloworld.pdf';
@ -11,7 +11,7 @@ var pdfPath = '../helloworld/helloworld.pdf';
// however that might degrade the UI performance in web browsers. // however that might degrade the UI performance in web browsers.
// Loading a document. // Loading a document.
var loadingTask = PDFJS.getDocument(pdfPath); var loadingTask = pdfjsLib.getDocument(pdfPath);
loadingTask.promise.then(function (pdfDocument) { loadingTask.promise.then(function (pdfDocument) {
// Request a first page // Request a first page
return pdfDocument.getPage(1).then(function (pdfPage) { return pdfDocument.getPage(1).then(function (pdfPage) {

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals pdfjsFilePath */ /* globals pdfjsFilePath, pdfjsVersion, pdfjsBuild */
'use strict'; 'use strict';
@ -2051,6 +2051,13 @@ var _UnsupportedManager = (function UnsupportedManagerClosure() {
}; };
})(); })();
if (typeof pdfjsVersion !== 'undefined') {
exports.version = pdfjsVersion;
}
if (typeof pdfjsBuild !== 'undefined') {
exports.build = pdfjsBuild;
}
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.PDFDataRangeTransport = PDFDataRangeTransport; exports.PDFDataRangeTransport = PDFDataRangeTransport;
exports.PDFWorker = PDFWorker; exports.PDFWorker = PDFWorker;

View File

@ -40,9 +40,11 @@
// Sync the exports below with ./pdf.js file/template. // Sync the exports below with ./pdf.js file/template.
exports.PDFJS = displayGlobal.PDFJS; exports.PDFJS = displayGlobal.PDFJS;
exports.build = displayAPI.build;
exports.version = displayAPI.version;
exports.getDocument = displayAPI.getDocument; exports.getDocument = displayAPI.getDocument;
exports.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; exports.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
exports.PDFWorker = displayAPI.PDFWorker;
exports.renderTextLayer = displayTextLayer.renderTextLayer; exports.renderTextLayer = displayTextLayer.renderTextLayer;
exports.AnnotationLayer = displayAnnotationLayer.AnnotationLayer; exports.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
exports.CustomStyle = displayDOMUtils.CustomStyle; exports.CustomStyle = displayDOMUtils.CustomStyle;
@ -51,4 +53,14 @@
exports.MissingPDFException = sharedUtil.MissingPDFException; exports.MissingPDFException = sharedUtil.MissingPDFException;
exports.SVGGraphics = displaySVG.SVGGraphics; exports.SVGGraphics = displaySVG.SVGGraphics;
exports.UnexpectedResponseException = sharedUtil.UnexpectedResponseException; exports.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
exports.OPS = sharedUtil.OPS;
exports.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
exports.isValidUrl = sharedUtil.isValidUrl;
exports.createObjectURL = sharedUtil.createObjectURL;
exports.removeNullCharacters = sharedUtil.removeNullCharacters;
exports.shadow = sharedUtil.shadow;
exports.createBlob = sharedUtil.createBlob;
exports.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
exports.addLinkAttributes = displayDOMUtils.addLinkAttributes;
})); }));

View File

@ -45,9 +45,12 @@
//#if MAIN_FILE //#if MAIN_FILE
exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS; exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument; exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
exports.PDFDataRangeTransport = exports.PDFDataRangeTransport =
pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport; pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer; exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
exports.AnnotationLayer = exports.AnnotationLayer =
pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer; pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
@ -58,6 +61,16 @@
exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics; exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
exports.UnexpectedResponseException = exports.UnexpectedResponseException =
pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException; pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
exports.isValidUrl = pdfjsLibs.pdfjsSharedUtil.isValidUrl;
exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
exports.getFilenameFromUrl =
pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
//#else //#else
exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler; exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
//#endif //#endif

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/*globals PDFJS, mozL10n, SimpleLinkService */ /*globals pdfjsLib, mozL10n, SimpleLinkService */
'use strict'; 'use strict';
@ -68,7 +68,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
if (self.div) { if (self.div) {
// If an annotationLayer already exists, refresh its children's // If an annotationLayer already exists, refresh its children's
// transformation matrices. // transformation matrices.
PDFJS.AnnotationLayer.update(parameters); pdfjsLib.AnnotationLayer.update(parameters);
} else { } else {
// Create an annotation layer div and render the annotations // Create an annotation layer div and render the annotations
// if there is at least one annotation. // if there is at least one annotation.
@ -81,7 +81,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() {
self.pageDiv.appendChild(self.div); self.pageDiv.appendChild(self.div);
parameters.div = self.div; parameters.div = self.div;
PDFJS.AnnotationLayer.render(parameters); pdfjsLib.AnnotationLayer.render(parameters);
if (typeof mozL10n !== 'undefined') { if (typeof mozL10n !== 'undefined') {
mozL10n.translate(self.div); mozL10n.translate(self.div);
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS, PDFBug, FirefoxCom, Stats, ProgressBar, DownloadManager, /* globals pdfjsLib, PDFBug, FirefoxCom, Stats, ProgressBar, DownloadManager,
getPDFFileNameFromURL, PDFHistory, Preferences, SidebarView, getPDFFileNameFromURL, PDFHistory, Preferences, SidebarView,
ViewHistory, Stats, PDFThumbnailViewer, URL, noContextMenuHandler, ViewHistory, Stats, PDFThumbnailViewer, URL, noContextMenuHandler,
SecondaryToolbar, PasswordPrompt, PDFPresentationMode, PDFSidebar, SecondaryToolbar, PasswordPrompt, PDFPresentationMode, PDFSidebar,
@ -20,8 +20,7 @@
PDFOutlineViewer, PDFAttachmentViewer, OverlayManager, PDFOutlineViewer, PDFAttachmentViewer, OverlayManager,
PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue, PDFFindController, PDFFindBar, PDFViewer, PDFRenderingQueue,
PresentationModeState, parseQueryString, RenderingStates, PresentationModeState, parseQueryString, RenderingStates,
UNKNOWN_SCALE, DEFAULT_SCALE_VALUE, DEFAULT_URL, mozL10n, UNKNOWN_SCALE, DEFAULT_SCALE_VALUE, DEFAULT_URL, mozL10n */
IGNORE_CURRENT_POSITION_ON_ZOOM: true */
'use strict'; 'use strict';
@ -108,7 +107,7 @@ var PDFViewerApplication = {
// called once when the document is loaded // called once when the document is loaded
initialize: function pdfViewInitialize() { initialize: function pdfViewInitialize() {
configure(PDFJS); configure(pdfjsLib.PDFJS);
var pdfRenderingQueue = new PDFRenderingQueue(); var pdfRenderingQueue = new PDFRenderingQueue();
pdfRenderingQueue.onIdle = this.cleanup.bind(this); pdfRenderingQueue.onIdle = this.cleanup.bind(this);
@ -263,6 +262,7 @@ var PDFViewerApplication = {
this.pdfSidebar.onToggled = this.forceRendering.bind(this); this.pdfSidebar.onToggled = this.forceRendering.bind(this);
var self = this; var self = this;
var PDFJS = pdfjsLib.PDFJS;
var initializedPromise = Promise.all([ var initializedPromise = Promise.all([
Preferences.get('enableWebGL').then(function resolved(value) { Preferences.get('enableWebGL').then(function resolved(value) {
PDFJS.disableWebGL = !value; PDFJS.disableWebGL = !value;
@ -369,7 +369,7 @@ var PDFViewerApplication = {
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
var value = 'mozPrintCallback' in canvas; var value = 'mozPrintCallback' in canvas;
return PDFJS.shadow(this, 'supportsPrinting', value); return pdfjsLib.shadow(this, 'supportsPrinting', value);
}, },
get supportsFullscreen() { get supportsFullscreen() {
@ -383,11 +383,11 @@ var PDFViewerApplication = {
document.msFullscreenEnabled === false) { document.msFullscreenEnabled === false) {
support = false; support = false;
} }
if (support && PDFJS.disableFullscreen === true) { if (support && pdfjsLib.PDFJS.disableFullscreen === true) {
support = false; support = false;
} }
return PDFJS.shadow(this, 'supportsFullscreen', support); return pdfjsLib.shadow(this, 'supportsFullscreen', support);
}, },
get supportsIntegratedFind() { get supportsIntegratedFind() {
@ -396,7 +396,7 @@ var PDFViewerApplication = {
// support = FirefoxCom.requestSync('supportsIntegratedFind'); // support = FirefoxCom.requestSync('supportsIntegratedFind');
//#endif //#endif
return PDFJS.shadow(this, 'supportsIntegratedFind', support); return pdfjsLib.shadow(this, 'supportsIntegratedFind', support);
}, },
get supportsDocumentFonts() { get supportsDocumentFonts() {
@ -405,7 +405,7 @@ var PDFViewerApplication = {
// support = FirefoxCom.requestSync('supportsDocumentFonts'); // support = FirefoxCom.requestSync('supportsDocumentFonts');
//#endif //#endif
return PDFJS.shadow(this, 'supportsDocumentFonts', support); return pdfjsLib.shadow(this, 'supportsDocumentFonts', support);
}, },
get supportsDocumentColors() { get supportsDocumentColors() {
@ -414,13 +414,13 @@ var PDFViewerApplication = {
// support = FirefoxCom.requestSync('supportsDocumentColors'); // support = FirefoxCom.requestSync('supportsDocumentColors');
//#endif //#endif
return PDFJS.shadow(this, 'supportsDocumentColors', support); return pdfjsLib.shadow(this, 'supportsDocumentColors', support);
}, },
get loadingBar() { get loadingBar() {
var bar = new ProgressBar('#loadingBar', {}); var bar = new ProgressBar('#loadingBar', {});
return PDFJS.shadow(this, 'loadingBar', bar); return pdfjsLib.shadow(this, 'loadingBar', bar);
}, },
get supportedMouseWheelZoomModifierKeys() { get supportedMouseWheelZoomModifierKeys() {
@ -432,16 +432,17 @@ var PDFViewerApplication = {
// support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys'); // support = FirefoxCom.requestSync('supportedMouseWheelZoomModifierKeys');
//#endif //#endif
return PDFJS.shadow(this, 'supportedMouseWheelZoomModifierKeys', support); return pdfjsLib.shadow(this, 'supportedMouseWheelZoomModifierKeys',
support);
}, },
//#if (FIREFOX || MOZCENTRAL) //#if (FIREFOX || MOZCENTRAL)
initPassiveLoading: function pdfViewInitPassiveLoading() { initPassiveLoading: function pdfViewInitPassiveLoading() {
function FirefoxComDataRangeTransport(length, initialData) { function FirefoxComDataRangeTransport(length, initialData) {
PDFJS.PDFDataRangeTransport.call(this, length, initialData); pdfjsLib.PDFDataRangeTransport.call(this, length, initialData);
} }
FirefoxComDataRangeTransport.prototype = FirefoxComDataRangeTransport.prototype =
Object.create(PDFJS.PDFDataRangeTransport.prototype); Object.create(pdfjsLib.PDFDataRangeTransport.prototype);
FirefoxComDataRangeTransport.prototype.requestDataRange = FirefoxComDataRangeTransport.prototype.requestDataRange =
function FirefoxComDataRangeTransport_requestDataRange(begin, end) { function FirefoxComDataRangeTransport_requestDataRange(begin, end) {
FirefoxCom.request('requestDataRange', { begin: begin, end: end }); FirefoxCom.request('requestDataRange', { begin: begin, end: end });
@ -507,7 +508,8 @@ var PDFViewerApplication = {
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) { setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
this.url = url; this.url = url;
try { try {
this.setTitle(decodeURIComponent(PDFJS.getFilenameFromUrl(url)) || url); this.setTitle(decodeURIComponent(
pdfjsLib.getFilenameFromUrl(url)) || url);
} catch (e) { } catch (e) {
// decodeURIComponent may throw URIError, // decodeURIComponent may throw URIError,
// fall back to using the unprocessed url in that case // fall back to using the unprocessed url in that case
@ -618,7 +620,7 @@ var PDFViewerApplication = {
var self = this; var self = this;
self.downloadComplete = false; self.downloadComplete = false;
var loadingTask = PDFJS.getDocument(parameters); var loadingTask = pdfjsLib.getDocument(parameters);
this.pdfLoadingTask = loadingTask; this.pdfLoadingTask = loadingTask;
loadingTask.onPassword = function passwordNeeded(updatePassword, reason) { loadingTask.onPassword = function passwordNeeded(updatePassword, reason) {
@ -643,15 +645,15 @@ var PDFViewerApplication = {
var loadingErrorMessage = mozL10n.get('loading_error', null, var loadingErrorMessage = mozL10n.get('loading_error', null,
'An error occurred while loading the PDF.'); 'An error occurred while loading the PDF.');
if (exception instanceof PDFJS.InvalidPDFException) { if (exception instanceof pdfjsLib.InvalidPDFException) {
// change error message also for other builds // change error message also for other builds
loadingErrorMessage = mozL10n.get('invalid_file_error', null, loadingErrorMessage = mozL10n.get('invalid_file_error', null,
'Invalid or corrupted PDF file.'); 'Invalid or corrupted PDF file.');
} else if (exception instanceof PDFJS.MissingPDFException) { } else if (exception instanceof pdfjsLib.MissingPDFException) {
// special message for missing PDF's // special message for missing PDF's
loadingErrorMessage = mozL10n.get('missing_file_error', null, loadingErrorMessage = mozL10n.get('missing_file_error', null,
'Missing PDF file.'); 'Missing PDF file.');
} else if (exception instanceof PDFJS.UnexpectedResponseException) { } else if (exception instanceof pdfjsLib.UnexpectedResponseException) {
loadingErrorMessage = mozL10n.get('unexpected_response_error', null, loadingErrorMessage = mozL10n.get('unexpected_response_error', null,
'Unexpected server response.'); 'Unexpected server response.');
} }
@ -697,7 +699,7 @@ var PDFViewerApplication = {
this.pdfDocument.getData().then( this.pdfDocument.getData().then(
function getDataSuccess(data) { function getDataSuccess(data) {
var blob = PDFJS.createBlob(data, 'application/pdf'); var blob = pdfjsLib.createBlob(data, 'application/pdf');
downloadManager.download(blob, url, filename); downloadManager.download(blob, url, filename);
}, },
downloadByUrl // Error occurred try downloading with just the url. downloadByUrl // Error occurred try downloading with just the url.
@ -737,7 +739,7 @@ var PDFViewerApplication = {
*/ */
error: function pdfViewError(message, moreInfo) { error: function pdfViewError(message, moreInfo) {
var moreInfoText = mozL10n.get('error_version_info', var moreInfoText = mozL10n.get('error_version_info',
{version: PDFJS.version || '?', build: PDFJS.build || '?'}, {version: pdfjsLib.version || '?', build: pdfjsLib.build || '?'},
'PDF.js v{{version}} (build: {{build}})') + '\n'; 'PDF.js v{{version}} (build: {{build}})') + '\n';
if (moreInfo) { if (moreInfo) {
moreInfoText += moreInfoText +=
@ -813,7 +815,7 @@ var PDFViewerApplication = {
// the loading bar will not be completely filled, nor will it be hidden. // the loading bar will not be completely filled, nor will it be hidden.
// To prevent displaying a partially filled loading bar permanently, we // To prevent displaying a partially filled loading bar permanently, we
// hide it when no data has been loaded during a certain amount of time. // hide it when no data has been loaded during a certain amount of time.
if (PDFJS.disableAutoFetch && percent) { if (pdfjsLib.PDFJS.disableAutoFetch && percent) {
if (this.disableAutoFetchLoadingBarTimeout) { if (this.disableAutoFetchLoadingBarTimeout) {
clearTimeout(this.disableAutoFetchLoadingBarTimeout); clearTimeout(this.disableAutoFetchLoadingBarTimeout);
this.disableAutoFetchLoadingBarTimeout = null; this.disableAutoFetchLoadingBarTimeout = null;
@ -881,7 +883,7 @@ var PDFViewerApplication = {
self.loadingBar.setWidth(document.getElementById('viewer')); self.loadingBar.setWidth(document.getElementById('viewer'));
if (!PDFJS.disableHistory && !self.isViewerEmbedded) { if (!pdfjsLib.PDFJS.disableHistory && !self.isViewerEmbedded) {
// The browsing history is only enabled when the viewer is standalone, // The browsing history is only enabled when the viewer is standalone,
// i.e. not when it is embedded in a web page. // i.e. not when it is embedded in a web page.
if (!self.preferenceShowPreviousViewOnLoad) { if (!self.preferenceShowPreviousViewOnLoad) {
@ -954,7 +956,7 @@ var PDFViewerApplication = {
pdfDocument.getJavaScript().then(function(javaScript) { pdfDocument.getJavaScript().then(function(javaScript) {
if (javaScript.length) { if (javaScript.length) {
console.warn('Warning: JavaScript is not supported'); console.warn('Warning: JavaScript is not supported');
self.fallback(PDFJS.UNSUPPORTED_FEATURES.javaScript); self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.javaScript);
} }
// Hack to support auto printing. // Hack to support auto printing.
var regex = /\bprint\s*\(/; var regex = /\bprint\s*\(/;
@ -991,8 +993,8 @@ var PDFViewerApplication = {
console.log('PDF ' + pdfDocument.fingerprint + ' [' + console.log('PDF ' + pdfDocument.fingerprint + ' [' +
info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() + info.PDFFormatVersion + ' ' + (info.Producer || '-').trim() +
' / ' + (info.Creator || '-').trim() + ']' + ' / ' + (info.Creator || '-').trim() + ']' +
' (PDF.js: ' + (PDFJS.version || '-') + ' (PDF.js: ' + (pdfjsLib.version || '-') +
(!PDFJS.disableWebGL ? ' [WebGL]' : '') + ')'); (!pdfjsLib.PDFJS.disableWebGL ? ' [WebGL]' : '') + ')');
var pdfTitle; var pdfTitle;
if (metadata && metadata.has('dc:title')) { if (metadata && metadata.has('dc:title')) {
@ -1013,7 +1015,7 @@ var PDFViewerApplication = {
if (info.IsAcroFormPresent) { if (info.IsAcroFormPresent) {
console.warn('Warning: AcroForm/XFA is not supported'); console.warn('Warning: AcroForm/XFA is not supported');
self.fallback(PDFJS.UNSUPPORTED_FEATURES.forms); self.fallback(pdfjsLib.UNSUPPORTED_FEATURES.forms);
} }
//#if !PRODUCTION //#if !PRODUCTION
@ -1296,9 +1298,7 @@ function webViewerInitialized() {
//document.getElementById('secondaryOpenFile').setAttribute('hidden', 'true'); //document.getElementById('secondaryOpenFile').setAttribute('hidden', 'true');
//#endif //#endif
//#if !(FIREFOX || MOZCENTRAL) var PDFJS = pdfjsLib.PDFJS;
var locale = PDFJS.locale || navigator.language;
//#endif
//#if !PRODUCTION //#if !PRODUCTION
if (true) { if (true) {
@ -1337,7 +1337,7 @@ function webViewerInitialized() {
PDFJS.verbosity = hashParams['verbosity'] | 0; PDFJS.verbosity = hashParams['verbosity'] | 0;
} }
if ('ignorecurrentpositiononzoom' in hashParams) { if ('ignorecurrentpositiononzoom' in hashParams) {
IGNORE_CURRENT_POSITION_ON_ZOOM = PDFJS.ignoreCurrentPositionOnZoom =
(hashParams['ignorecurrentpositiononzoom'] === 'true'); (hashParams['ignorecurrentpositiononzoom'] === 'true');
} }
//#if !PRODUCTION //#if !PRODUCTION
@ -1348,7 +1348,7 @@ function webViewerInitialized() {
//#endif //#endif
//#if !(FIREFOX || MOZCENTRAL) //#if !(FIREFOX || MOZCENTRAL)
if ('locale' in hashParams) { if ('locale' in hashParams) {
locale = hashParams['locale']; PDFJS.locale = hashParams['locale'];
} }
//#endif //#endif
if ('textlayer' in hashParams) { if ('textlayer' in hashParams) {
@ -1374,7 +1374,7 @@ function webViewerInitialized() {
} }
//#if !(FIREFOX || MOZCENTRAL) //#if !(FIREFOX || MOZCENTRAL)
mozL10n.setLanguage(locale); mozL10n.setLanguage(PDFJS.locale);
//#endif //#endif
//#if (FIREFOX || MOZCENTRAL) //#if (FIREFOX || MOZCENTRAL)
if (!PDFViewerApplication.supportsDocumentFonts) { if (!PDFViewerApplication.supportsDocumentFonts) {
@ -1518,7 +1518,7 @@ document.addEventListener('pagerendered', function (e) {
thumbnailView.setImage(pageView); thumbnailView.setImage(pageView);
} }
if (PDFJS.pdfBug && Stats.enabled && pageView.stats) { if (pdfjsLib.PDFJS.pdfBug && Stats.enabled && pageView.stats) {
Stats.add(pageNumber, pageView.stats); Stats.add(pageNumber, pageView.stats);
} }
@ -1711,7 +1711,7 @@ window.addEventListener('change', function webViewerChange(evt) {
} }
var file = files[0]; var file = files[0];
if (!PDFJS.disableCreateObjectURL && if (!pdfjsLib.PDFJS.disableCreateObjectURL &&
typeof URL !== 'undefined' && URL.createObjectURL) { typeof URL !== 'undefined' && URL.createObjectURL) {
PDFViewerApplication.open(URL.createObjectURL(file)); PDFViewerApplication.open(URL.createObjectURL(file));
} else { } else {
@ -1815,7 +1815,7 @@ window.addEventListener('pagechange', function pagechange(evt) {
document.getElementById('lastPage').disabled = (page >= numPages); document.getElementById('lastPage').disabled = (page >= numPages);
// we need to update stats // we need to update stats
if (PDFJS.pdfBug && Stats.enabled) { if (pdfjsLib.PDFJS.pdfBug && Stats.enabled) {
var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1); var pageView = PDFViewerApplication.pdfViewer.getPageView(page - 1);
if (pageView.stats) { if (pageView.stats) {
Stats.add(page, pageView.stats); Stats.add(page, pageView.stats);

View File

@ -13,7 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
/* globals chrome, PDFJS, PDFViewerApplication, OverlayManager */ /* globals chrome, pdfjsLib, PDFViewerApplication, OverlayManager */
'use strict'; 'use strict';
var ChromeCom = (function ChromeComClosure() { var ChromeCom = (function ChromeComClosure() {
@ -81,7 +81,7 @@ var ChromeCom = (function ChromeComClosure() {
return; return;
} }
} }
if (/^filesystem:/.test(file) && !PDFJS.disableWorker) { if (/^filesystem:/.test(file) && !pdfjsLib.PDFJS.disableWorker) {
// The security origin of filesystem:-URLs are not preserved when the // The security origin of filesystem:-URLs are not preserved when the
// URL is passed to a Web worker, (http://crbug.com/362061), so we have // URL is passed to a Web worker, (http://crbug.com/362061), so we have
// to create an intermediate blob:-URL as a work-around. // to create an intermediate blob:-URL as a work-around.

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS */ /* globals pdfjsLib */
'use strict'; 'use strict';
@ -307,8 +307,8 @@ var Stepper = (function StepperClosure() {
this.table = table; this.table = table;
if (!opMap) { if (!opMap) {
opMap = Object.create(null); opMap = Object.create(null);
for (var key in PDFJS.OPS) { for (var key in pdfjsLib.OPS) {
opMap[PDFJS.OPS[key]] = key; opMap[pdfjsLib.OPS[key]] = key;
} }
} }
}, },
@ -460,7 +460,7 @@ var Stats = (function Stats() {
manager: null, manager: null,
init: function init() { init: function init() {
this.panel.setAttribute('style', 'padding: 5px;'); this.panel.setAttribute('style', 'padding: 5px;');
PDFJS.enableStats = true; pdfjsLib.PDFJS.enableStats = true;
}, },
enabled: false, enabled: false,
active: false, active: false,

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals URL, PDFJS */ /* globals URL, pdfjsLib */
'use strict'; 'use strict';
@ -58,7 +58,7 @@ var DownloadManager = (function DownloadManagerClosure() {
DownloadManager.prototype = { DownloadManager.prototype = {
downloadUrl: function DownloadManager_downloadUrl(url, filename) { downloadUrl: function DownloadManager_downloadUrl(url, filename) {
if (!PDFJS.isValidUrl(url, true)) { if (!pdfjsLib.isValidUrl(url, true)) {
return; // restricted/invalid URL return; // restricted/invalid URL
} }
@ -72,7 +72,8 @@ var DownloadManager = (function DownloadManagerClosure() {
filename); filename);
} }
var blobUrl = PDFJS.createObjectURL(data, contentType); var blobUrl = pdfjsLib.createObjectURL(data, contentType,
pdfjsLib.PDFJS.disableCreateObjectURL);
download(blobUrl, filename); download(blobUrl, filename);
}, },

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals Preferences, PDFJS, Promise */ /* globals Preferences, pdfjsLib, Promise */
'use strict'; 'use strict';
@ -87,7 +87,7 @@ var DownloadManager = (function DownloadManagerClosure() {
downloadData: function DownloadManager_downloadData(data, filename, downloadData: function DownloadManager_downloadData(data, filename,
contentType) { contentType) {
var blobUrl = PDFJS.createObjectURL(data, contentType); var blobUrl = pdfjsLib.createObjectURL(data, contentType, false);
FirefoxCom.request('download', { FirefoxCom.request('download', {
blobUrl: blobUrl, blobUrl: blobUrl,

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS, mozL10n, OverlayManager */ /* globals pdfjsLib, mozL10n, OverlayManager */
'use strict'; 'use strict';
@ -55,7 +55,7 @@ var PasswordPrompt = {
var promptString = mozL10n.get('password_label', null, var promptString = mozL10n.get('password_label', null,
'Enter the password to open this PDF file.'); 'Enter the password to open this PDF file.');
if (this.reason === PDFJS.PasswordResponses.INCORRECT_PASSWORD) { if (this.reason === pdfjsLib.PasswordResponses.INCORRECT_PASSWORD) {
promptString = mozL10n.get('password_invalid', null, promptString = mozL10n.get('password_invalid', null,
'Invalid password. Please try again.'); 'Invalid password. Please try again.');
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS */ /* globals pdfjsLib */
'use strict'; 'use strict';
@ -98,12 +98,12 @@ var PDFAttachmentViewer = (function PDFAttachmentViewerClosure() {
for (var i = 0; i < attachmentsCount; i++) { for (var i = 0; i < attachmentsCount; i++) {
var item = attachments[names[i]]; var item = attachments[names[i]];
var filename = PDFJS.getFilenameFromUrl(item.filename); var filename = pdfjsLib.getFilenameFromUrl(item.filename);
var div = document.createElement('div'); var div = document.createElement('div');
div.className = 'attachmentsItem'; div.className = 'attachmentsItem';
var button = document.createElement('button'); var button = document.createElement('button');
this._bindLink(button, item.content, filename); this._bindLink(button, item.content, filename);
button.textContent = PDFJS.removeNullCharacters(filename); button.textContent = pdfjsLib.removeNullCharacters(filename);
div.appendChild(button); div.appendChild(button);
this.container.appendChild(div); this.container.appendChild(div);
} }

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS, FirefoxCom, Promise, scrollIntoView */ /* globals FirefoxCom, Promise, scrollIntoView */
'use strict'; 'use strict';

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS */ /* globals pdfjsLib */
'use strict'; 'use strict';
@ -71,7 +71,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
*/ */
_bindLink: function PDFOutlineViewer_bindLink(element, item) { _bindLink: function PDFOutlineViewer_bindLink(element, item) {
if (item.url) { if (item.url) {
PDFJS.addLinkAttributes(element, { url: item.url }); pdfjsLib.addLinkAttributes(element, { url: item.url });
return; return;
} }
var linkService = this.linkService; var linkService = this.linkService;
@ -180,7 +180,7 @@ var PDFOutlineViewer = (function PDFOutlineViewerClosure() {
this._bindLink(element, item); this._bindLink(element, item);
this._setStyles(element, item); this._setStyles(element, item);
element.textContent = element.textContent =
PDFJS.removeNullCharacters(item.title) || DEFAULT_TITLE; pdfjsLib.removeNullCharacters(item.title) || DEFAULT_TITLE;
div.appendChild(element); div.appendChild(element);

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals RenderingStates, PDFJS, DEFAULT_SCALE, CSS_UNITS, getOutputScale, /* globals RenderingStates, pdfjsLib, DEFAULT_SCALE, CSS_UNITS, getOutputScale,
TextLayerBuilder, Promise, approximateFraction, roundToDivide */ TextLayerBuilder, Promise, approximateFraction, roundToDivide */
'use strict'; 'use strict';
@ -162,19 +162,18 @@ var PDFPageView = (function PDFPageViewClosure() {
}); });
var isScalingRestricted = false; var isScalingRestricted = false;
if (this.canvas && PDFJS.maxCanvasPixels > 0) { if (this.canvas && pdfjsLib.PDFJS.maxCanvasPixels > 0) {
var outputScale = this.outputScale; var outputScale = this.outputScale;
var pixelsInViewport = this.viewport.width * this.viewport.height; var pixelsInViewport = this.viewport.width * this.viewport.height;
var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport);
if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) * if (((Math.floor(this.viewport.width) * outputScale.sx) | 0) *
((Math.floor(this.viewport.height) * outputScale.sy) | 0) > ((Math.floor(this.viewport.height) * outputScale.sy) | 0) >
PDFJS.maxCanvasPixels) { pdfjsLib.PDFJS.maxCanvasPixels) {
isScalingRestricted = true; isScalingRestricted = true;
} }
} }
if (this.canvas) { if (this.canvas) {
if (PDFJS.useOnlyCssZoom || if (pdfjsLib.PDFJS.useOnlyCssZoom ||
(this.hasRestrictedScaling && isScalingRestricted)) { (this.hasRestrictedScaling && isScalingRestricted)) {
this.cssTransform(this.canvas, true); this.cssTransform(this.canvas, true);
@ -208,7 +207,7 @@ var PDFPageView = (function PDFPageViewClosure() {
}, },
cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) { cssTransform: function PDFPageView_transform(canvas, redrawAnnotations) {
var CustomStyle = PDFJS.CustomStyle; var CustomStyle = pdfjsLib.CustomStyle;
// Scale canvas, canvas wrapper, and page container. // Scale canvas, canvas wrapper, and page container.
var width = this.viewport.width; var width = this.viewport.width;
@ -330,7 +329,7 @@ var PDFPageView = (function PDFPageViewClosure() {
var outputScale = getOutputScale(ctx); var outputScale = getOutputScale(ctx);
this.outputScale = outputScale; this.outputScale = outputScale;
if (PDFJS.useOnlyCssZoom) { if (pdfjsLib.PDFJS.useOnlyCssZoom) {
var actualSizeViewport = viewport.clone({scale: CSS_UNITS}); var actualSizeViewport = viewport.clone({scale: CSS_UNITS});
// Use a scale that will make the canvas be the original intended size // Use a scale that will make the canvas be the original intended size
// of the page. // of the page.
@ -339,9 +338,10 @@ var PDFPageView = (function PDFPageViewClosure() {
outputScale.scaled = true; outputScale.scaled = true;
} }
if (PDFJS.maxCanvasPixels > 0) { if (pdfjsLib.PDFJS.maxCanvasPixels > 0) {
var pixelsInViewport = viewport.width * viewport.height; var pixelsInViewport = viewport.width * viewport.height;
var maxScale = Math.sqrt(PDFJS.maxCanvasPixels / pixelsInViewport); var maxScale =
Math.sqrt(pdfjsLib.PDFJS.maxCanvasPixels / pixelsInViewport);
if (outputScale.sx > maxScale || outputScale.sy > maxScale) { if (outputScale.sx > maxScale || outputScale.sy > maxScale) {
outputScale.sx = maxScale; outputScale.sx = maxScale;
outputScale.sy = maxScale; outputScale.sy = maxScale;
@ -517,7 +517,7 @@ var PDFPageView = (function PDFPageViewClosure() {
}, },
beforePrint: function PDFPageView_beforePrint() { beforePrint: function PDFPageView_beforePrint() {
var CustomStyle = PDFJS.CustomStyle; var CustomStyle = pdfjsLib.CustomStyle;
var pdfPage = this.pdfPage; var pdfPage = this.pdfPage;
var viewport = pdfPage.getViewport(1); var viewport = pdfPage.getViewport(1);

View File

@ -17,14 +17,21 @@
DefaultTextLayerFactory, AnnotationLayerBuilder, PDFHistory, DefaultTextLayerFactory, AnnotationLayerBuilder, PDFHistory,
DefaultAnnotationLayerFactory, DownloadManager, ProgressBar */ DefaultAnnotationLayerFactory, DownloadManager, ProgressBar */
// Initializing PDFJS global object (if still undefined)
if (typeof PDFJS === 'undefined') {
(typeof window !== 'undefined' ? window : this).PDFJS = {};
}
(function pdfViewerWrapper() { (function pdfViewerWrapper() {
'use strict'; 'use strict';
var root = this;
if (!root.pdfjsLib) {
Object.defineProperty(root, 'pdfjsLib', {
get: function () {
return root.pdfjsDistBuildPdf || root.pdfjsDistBuildPdfCombined ||
root.pdfjsMainLoader;
},
enumerable: true,
configurable: true
});
}
//#include ui_utils.js //#include ui_utils.js
//#include pdf_link_service.js //#include pdf_link_service.js
//#include pdf_viewer.js //#include pdf_viewer.js

View File

@ -15,7 +15,7 @@
/*globals watchScroll, PDFPageView, UNKNOWN_SCALE, /*globals watchScroll, PDFPageView, UNKNOWN_SCALE,
SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS, SCROLLBAR_PADDING, VERTICAL_PADDING, MAX_AUTO_SCALE, CSS_UNITS,
DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates, DEFAULT_SCALE, scrollIntoView, getVisibleElements, RenderingStates,
PDFJS, Promise, TextLayerBuilder, PDFRenderingQueue, pdfjsLib, Promise, TextLayerBuilder, PDFRenderingQueue,
AnnotationLayerBuilder, DEFAULT_SCALE_VALUE */ AnnotationLayerBuilder, DEFAULT_SCALE_VALUE */
'use strict'; 'use strict';
@ -27,7 +27,6 @@ var PresentationModeState = {
FULLSCREEN: 3, FULLSCREEN: 3,
}; };
var IGNORE_CURRENT_POSITION_ON_ZOOM = false;
var DEFAULT_CACHE_SIZE = 10; var DEFAULT_CACHE_SIZE = 10;
//#include pdf_rendering_queue.js //#include pdf_rendering_queue.js
@ -287,7 +286,7 @@ var PDFViewer = (function pdfViewer() {
var viewport = pdfPage.getViewport(scale * CSS_UNITS); var viewport = pdfPage.getViewport(scale * CSS_UNITS);
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
var textLayerFactory = null; var textLayerFactory = null;
if (!PDFJS.disableTextLayer) { if (!pdfjsLib.PDFJS.disableTextLayer) {
textLayerFactory = this; textLayerFactory = this;
} }
var pageView = new PDFPageView({ var pageView = new PDFPageView({
@ -309,7 +308,7 @@ var PDFViewer = (function pdfViewer() {
// starts to create the correct size canvas. Wait until one page is // starts to create the correct size canvas. Wait until one page is
// rendered so we don't tie up too many resources early on. // rendered so we don't tie up too many resources early on.
onePageRendered.then(function () { onePageRendered.then(function () {
if (!PDFJS.disableAutoFetch) { if (!pdfjsLib.PDFJS.disableAutoFetch) {
var getPagesLeft = pagesCount; var getPagesLeft = pagesCount;
for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) { for (var pageNum = 1; pageNum <= pagesCount; ++pageNum) {
pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) { pdfDocument.getPage(pageNum).then(function (pageNum, pdfPage) {
@ -399,7 +398,7 @@ var PDFViewer = (function pdfViewer() {
if (!noScroll) { if (!noScroll) {
var page = this._currentPageNumber, dest; var page = this._currentPageNumber, dest;
if (this._location && !IGNORE_CURRENT_POSITION_ON_ZOOM && if (this._location && !pdfjsLib.PDFJS.ignoreCurrentPositionOnZoom &&
!(this.isInPresentationMode || this.isChangingPresentationMode)) { !(this.isInPresentationMode || this.isChangingPresentationMode)) {
page = this._location.pageNumber; page = this._location.pageNumber;
dest = [null, { name: 'XYZ' }, this._location.left, dest = [null, { name: 'XYZ' }, this._location.left,

View File

@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* globals PDFJS */ /* globals pdfjsLib */
'use strict'; 'use strict';
@ -78,7 +78,7 @@ var TextLayerBuilder = (function TextLayerBuilderClosure() {
this.textDivs = []; this.textDivs = [];
var textLayerFrag = document.createDocumentFragment(); var textLayerFrag = document.createDocumentFragment();
this.textLayerRenderTask = PDFJS.renderTextLayer({ this.textLayerRenderTask = pdfjsLib.renderTextLayer({
textContent: this.textContent, textContent: this.textContent,
container: textLayerFrag, container: textLayerFrag,
viewport: this.viewport, viewport: this.viewport,

View File

@ -27,7 +27,7 @@ var VERTICAL_PADDING = 5;
var mozL10n = document.mozL10n || document.webL10n; var mozL10n = document.mozL10n || document.webL10n;
if (typeof PDFJS === 'undefined') { if (typeof PDFJS === 'undefined') {
window.PDFJS = {}; (typeof window !== 'undefined' ? window : this).PDFJS = {};
} }
/** /**
@ -53,6 +53,34 @@ PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ? PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
16777216 : PDFJS.maxCanvasPixels); 16777216 : PDFJS.maxCanvasPixels);
/**
* Disables saving of the last position of the viewed PDF.
* @var {boolean}
*/
PDFJS.disableHistory = (PDFJS.disableHistory === undefined ?
false : PDFJS.disableHistory);
/**
* Disables creation of the text layer that used for text selection and search.
* @var {boolean}
*/
PDFJS.disableTextLayer = (PDFJS.disableTextLayer === undefined ?
false : PDFJS.disableTextLayer);
/**
* Disables maintaining the current position in the document when zooming.
*/
PDFJS.ignoreCurrentPositionOnZoom = (PDFJS.ignoreCurrentPositionOnZoom ===
undefined ? false : PDFJS.ignoreCurrentPositionOnZoom);
//#if !(FIREFOX || MOZCENTRAL)
/**
* Interface locale settings.
* @var {string}
*/
PDFJS.locale = (PDFJS.locale === undefined ? navigator.language : PDFJS.locale);
//#endif
/** /**
* Returns scale factor for the canvas. It makes sense for the HiDPI displays. * Returns scale factor for the canvas. It makes sense for the HiDPI displays.
* @return {Object} The object with horizontal (sx) and vertical (sy) * @return {Object} The object with horizontal (sx) and vertical (sy)

View File

@ -41,9 +41,11 @@ function webViewerLoad() {
//#if !PRODUCTION //#if !PRODUCTION
require.config({paths: {'pdfjs': '../src'}}); require.config({paths: {'pdfjs': '../src'}});
require(['pdfjs/main_loader'], function (loader) { require(['pdfjs/main_loader'], function (loader) {
window.pdfjsLib = loader;
PDFViewerApplication.run(); PDFViewerApplication.run();
}); });
//#else //#else
//window.pdfjsLib = window.pdfjsDistBuildPdf;
//PDFViewerApplication.run(); //PDFViewerApplication.run();
//#endif //#endif
} }