Merge pull request #7126 from yurydelendik/rm-pdfjs-display
Move all PDFJS display/ usages into global.js file.
This commit is contained in:
commit
68e8f5fff5
@ -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) {
|
||||||
|
@ -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) {
|
||||||
|
@ -120,10 +120,6 @@ DOMElement.prototype = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
global.window = global;
|
|
||||||
|
|
||||||
global.navigator = { userAgent: 'node' };
|
|
||||||
|
|
||||||
global.document = {
|
global.document = {
|
||||||
childNodes : [],
|
childNodes : [],
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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();
|
||||||
|
@ -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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -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) {
|
||||||
|
8
make.js
8
make.js
@ -198,6 +198,7 @@ target.jsdoc = function() {
|
|||||||
var JSDOC_FILES = [
|
var JSDOC_FILES = [
|
||||||
'src/doc_helper.js',
|
'src/doc_helper.js',
|
||||||
'src/display/api.js',
|
'src/display/api.js',
|
||||||
|
'src/display/global.js',
|
||||||
'src/shared/util.js',
|
'src/shared/util.js',
|
||||||
'src/core/annotation.js'
|
'src/core/annotation.js'
|
||||||
];
|
];
|
||||||
@ -527,9 +528,7 @@ target.bundle = function(args) {
|
|||||||
|
|
||||||
var umd = require('./external/umdutils/verifier.js');
|
var umd = require('./external/umdutils/verifier.js');
|
||||||
var MAIN_SRC_FILES = [
|
var MAIN_SRC_FILES = [
|
||||||
SRC_DIR + 'display/annotation_layer.js',
|
SRC_DIR + 'display/global.js'
|
||||||
SRC_DIR + 'display/text_layer.js',
|
|
||||||
SRC_DIR + 'display/api.js'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
var WORKER_SRC_FILES = [
|
var WORKER_SRC_FILES = [
|
||||||
@ -539,9 +538,8 @@ target.bundle = function(args) {
|
|||||||
var mainFileName = 'pdf.js';
|
var mainFileName = 'pdf.js';
|
||||||
var workerFileName = 'pdf.worker.js';
|
var workerFileName = 'pdf.worker.js';
|
||||||
|
|
||||||
// Extension does not need svg.js and network.js files.
|
// Extension does not need network.js file.
|
||||||
if (!defines.FIREFOX && !defines.MOZCENTRAL) {
|
if (!defines.FIREFOX && !defines.MOZCENTRAL) {
|
||||||
MAIN_SRC_FILES.push(SRC_DIR + 'display/svg.js');
|
|
||||||
WORKER_SRC_FILES.push(SRC_DIR + 'core/network.js');
|
WORKER_SRC_FILES.push(SRC_DIR + 'core/network.js');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
* 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 */
|
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -35,6 +34,7 @@ var addLinkAttributes = displayDOMUtils.addLinkAttributes;
|
|||||||
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
|
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||||
|
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} AnnotationElementParameters
|
* @typedef {Object} AnnotationElementParameters
|
||||||
@ -107,6 +107,7 @@ var AnnotationElement = (function AnnotationElementClosure() {
|
|||||||
this.viewport = parameters.viewport;
|
this.viewport = parameters.viewport;
|
||||||
this.linkService = parameters.linkService;
|
this.linkService = parameters.linkService;
|
||||||
this.downloadManager = parameters.downloadManager;
|
this.downloadManager = parameters.downloadManager;
|
||||||
|
this.imageResourcesPath = parameters.imageResourcesPath;
|
||||||
|
|
||||||
if (isRenderable) {
|
if (isRenderable) {
|
||||||
this.container = this._createContainer();
|
this.container = this._createContainer();
|
||||||
@ -363,7 +364,7 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() {
|
|||||||
var image = document.createElement('img');
|
var image = document.createElement('img');
|
||||||
image.style.height = this.container.style.height;
|
image.style.height = this.container.style.height;
|
||||||
image.style.width = this.container.style.width;
|
image.style.width = this.container.style.width;
|
||||||
image.src = PDFJS.imageResourcesPath + 'annotation-' +
|
image.src = this.imageResourcesPath + 'annotation-' +
|
||||||
this.data.name.toLowerCase() + '.svg';
|
this.data.name.toLowerCase() + '.svg';
|
||||||
image.alt = '[{{type}} Annotation]';
|
image.alt = '[{{type}} Annotation]';
|
||||||
image.dataset.l10nId = 'text_annotation_type';
|
image.dataset.l10nId = 'text_annotation_type';
|
||||||
@ -838,6 +839,7 @@ var FileAttachmentAnnotationElement = (
|
|||||||
* @property {Array} annotations
|
* @property {Array} annotations
|
||||||
* @property {PDFPage} page
|
* @property {PDFPage} page
|
||||||
* @property {IPDFLinkService} linkService
|
* @property {IPDFLinkService} linkService
|
||||||
|
* @property {string} imageResourcesPath
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -868,7 +870,9 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|||||||
page: parameters.page,
|
page: parameters.page,
|
||||||
viewport: parameters.viewport,
|
viewport: parameters.viewport,
|
||||||
linkService: parameters.linkService,
|
linkService: parameters.linkService,
|
||||||
downloadManager: parameters.downloadManager
|
downloadManager: parameters.downloadManager,
|
||||||
|
imageResourcesPath: parameters.imageResourcesPath ||
|
||||||
|
getDefaultSetting('imageResourcesPath')
|
||||||
};
|
};
|
||||||
var element = annotationElementFactory.create(properties);
|
var element = annotationElementFactory.create(properties);
|
||||||
if (element.isRenderable) {
|
if (element.isRenderable) {
|
||||||
@ -899,7 +903,5 @@ var AnnotationLayer = (function AnnotationLayerClosure() {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
PDFJS.AnnotationLayer = AnnotationLayer;
|
|
||||||
|
|
||||||
exports.AnnotationLayer = AnnotationLayer;
|
exports.AnnotationLayer = AnnotationLayer;
|
||||||
}));
|
}));
|
||||||
|
@ -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';
|
||||||
|
|
||||||
@ -21,23 +21,23 @@
|
|||||||
define('pdfjs/display/api', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/api', ['exports', 'pdfjs/shared/util',
|
||||||
'pdfjs/display/font_loader', 'pdfjs/display/canvas',
|
'pdfjs/display/font_loader', 'pdfjs/display/canvas',
|
||||||
'pdfjs/display/metadata', 'pdfjs/display/dom_utils',
|
'pdfjs/display/metadata', 'pdfjs/display/dom_utils',
|
||||||
'pdfjs/display/global', 'require'], factory);
|
'require'], factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./font_loader.js'),
|
factory(exports, require('../shared/util.js'), require('./font_loader.js'),
|
||||||
require('./canvas.js'), require('./metadata.js'),
|
require('./canvas.js'), require('./metadata.js'),
|
||||||
require('./dom_utils.js'), require('./global.js'));
|
require('./dom_utils.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil,
|
||||||
root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas,
|
root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas,
|
||||||
root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils,
|
root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
|
||||||
root.pdfjsDisplayGlobal);
|
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
|
}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
|
||||||
displayMetadata, displayDOMUtils, displayGlobal, amdRequire) {
|
displayMetadata, displayDOMUtils, amdRequire) {
|
||||||
|
|
||||||
var InvalidPDFException = sharedUtil.InvalidPDFException;
|
var InvalidPDFException = sharedUtil.InvalidPDFException;
|
||||||
var MessageHandler = sharedUtil.MessageHandler;
|
var MessageHandler = sharedUtil.MessageHandler;
|
||||||
var MissingPDFException = sharedUtil.MissingPDFException;
|
var MissingPDFException = sharedUtil.MissingPDFException;
|
||||||
|
var PageViewport = sharedUtil.PageViewport;
|
||||||
var PasswordResponses = sharedUtil.PasswordResponses;
|
var PasswordResponses = sharedUtil.PasswordResponses;
|
||||||
var PasswordException = sharedUtil.PasswordException;
|
var PasswordException = sharedUtil.PasswordException;
|
||||||
var StatTimer = sharedUtil.StatTimer;
|
var StatTimer = sharedUtil.StatTimer;
|
||||||
@ -54,17 +54,21 @@ var isArrayBuffer = sharedUtil.isArrayBuffer;
|
|||||||
var isSameOrigin = sharedUtil.isSameOrigin;
|
var isSameOrigin = sharedUtil.isSameOrigin;
|
||||||
var loadJpegStream = sharedUtil.loadJpegStream;
|
var loadJpegStream = sharedUtil.loadJpegStream;
|
||||||
var stringToBytes = sharedUtil.stringToBytes;
|
var stringToBytes = sharedUtil.stringToBytes;
|
||||||
|
var globalScope = sharedUtil.globalScope;
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
var FontFaceObject = displayFontLoader.FontFaceObject;
|
var FontFaceObject = displayFontLoader.FontFaceObject;
|
||||||
var FontLoader = displayFontLoader.FontLoader;
|
var FontLoader = displayFontLoader.FontLoader;
|
||||||
var CanvasGraphics = displayCanvas.CanvasGraphics;
|
var CanvasGraphics = displayCanvas.CanvasGraphics;
|
||||||
var createScratchCanvas = displayCanvas.createScratchCanvas;
|
var createScratchCanvas = displayCanvas.createScratchCanvas;
|
||||||
var Metadata = displayMetadata.Metadata;
|
var Metadata = displayMetadata.Metadata;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
var globalScope = displayGlobal.globalScope;
|
|
||||||
|
|
||||||
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||||
|
|
||||||
|
var isWorkerDisabled = false;
|
||||||
|
var workerSrc;
|
||||||
|
var isPostMessageTransfersDisabled = false;
|
||||||
|
|
||||||
//#if PRODUCTION && !SINGLE_FILE
|
//#if PRODUCTION && !SINGLE_FILE
|
||||||
//#if GENERIC
|
//#if GENERIC
|
||||||
//#include ../src/frameworks.js
|
//#include ../src/frameworks.js
|
||||||
@ -73,183 +77,6 @@ var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
|||||||
//#endif
|
//#endif
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum allowed image size in total pixels e.g. width * height. Images
|
|
||||||
* above this value will not be drawn. Use -1 for no limit.
|
|
||||||
* @var {number}
|
|
||||||
*/
|
|
||||||
PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
|
|
||||||
-1 : PDFJS.maxImageSize);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The url of where the predefined Adobe CMaps are located. Include trailing
|
|
||||||
* slash.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies if CMaps are binary packed.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* By default fonts are converted to OpenType fonts and loaded via font face
|
|
||||||
* rules. If disabled, the font will be rendered using a built in font renderer
|
|
||||||
* that constructs the glyphs with primitive path commands.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
|
||||||
false : PDFJS.disableFontFace);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path for image resources, mainly for annotation icons. Include trailing
|
|
||||||
* slash.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ?
|
|
||||||
'' : PDFJS.imageResourcesPath);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable the web worker and run all code on the main thread. This will happen
|
|
||||||
* automatically if the browser doesn't support workers or sending typed arrays
|
|
||||||
* to workers.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
|
|
||||||
false : PDFJS.disableWorker);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Path and filename of the worker file. Required when the worker is enabled in
|
|
||||||
* development mode. If unspecified in the production build, the worker will be
|
|
||||||
* loaded based on the location of the pdf.js file. It is recommended that
|
|
||||||
* the workerSrc is set in a custom application to prevent issues caused by
|
|
||||||
* third-party frameworks and libraries.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable range request loading of PDF files. When enabled and if the server
|
|
||||||
* supports partial content requests then the PDF will be fetched in chunks.
|
|
||||||
* Enabled (false) by default.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
|
||||||
false : PDFJS.disableRange);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
|
||||||
* in chunks. This default behavior can be disabled.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
|
||||||
false : PDFJS.disableStream);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable pre-fetching of PDF file data. When range requests are enabled PDF.js
|
|
||||||
* will automatically keep fetching more data even if it isn't needed to display
|
|
||||||
* the current page. This default behavior can be disabled.
|
|
||||||
*
|
|
||||||
* NOTE: It is also necessary to disable streaming, see above,
|
|
||||||
* in order for disabling of pre-fetching to work correctly.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
|
|
||||||
false : PDFJS.disableAutoFetch);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables special hooks for debugging PDF.js.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables transfer usage in postMessage for ArrayBuffers.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
|
|
||||||
true : PDFJS.postMessageTransfers);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables URL.createObjectURL usage.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
|
||||||
false : PDFJS.disableCreateObjectURL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables WebGL usage.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ?
|
|
||||||
true : PDFJS.disableWebGL);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disables fullscreen support, and by extension Presentation Mode,
|
|
||||||
* in browsers which support the fullscreen API.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ?
|
|
||||||
false : PDFJS.disableFullscreen);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables CSS only zooming.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
|
|
||||||
false : PDFJS.useOnlyCssZoom);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
|
||||||
* The default value is 4096 * 4096. Use -1 for no limit.
|
|
||||||
* @var {number}
|
|
||||||
*/
|
|
||||||
PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
|
||||||
16777216 : PDFJS.maxCanvasPixels);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* (Deprecated) Opens external links in a new window if enabled.
|
|
||||||
* The default behavior opens external links in the PDF.js window.
|
|
||||||
*
|
|
||||||
* NOTE: This property has been deprecated, please use
|
|
||||||
* `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.openExternalLinksInNewWindow = (
|
|
||||||
PDFJS.openExternalLinksInNewWindow === undefined ?
|
|
||||||
false : PDFJS.openExternalLinksInNewWindow);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the |target| attribute for external links.
|
|
||||||
* The constants from PDFJS.LinkTarget should be used:
|
|
||||||
* - NONE [default]
|
|
||||||
* - SELF
|
|
||||||
* - BLANK
|
|
||||||
* - PARENT
|
|
||||||
* - TOP
|
|
||||||
* @var {number}
|
|
||||||
*/
|
|
||||||
PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ?
|
|
||||||
PDFJS.LinkTarget.NONE : PDFJS.externalLinkTarget);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the |rel| attribute for external links. Defaults to stripping
|
|
||||||
* the referrer.
|
|
||||||
* @var {string}
|
|
||||||
*/
|
|
||||||
PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
|
|
||||||
'noreferrer' : PDFJS.externalLinkRel);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if we can eval strings as JS. Primarily used to improve
|
|
||||||
* performance for font rendering.
|
|
||||||
* @var {boolean}
|
|
||||||
*/
|
|
||||||
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
|
||||||
true : PDFJS.isEvalSupported);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Document initialization / loading parameters object.
|
* Document initialization / loading parameters object.
|
||||||
*
|
*
|
||||||
@ -309,10 +136,8 @@ PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
|||||||
*
|
*
|
||||||
* @return {PDFDocumentLoadingTask}
|
* @return {PDFDocumentLoadingTask}
|
||||||
*/
|
*/
|
||||||
PDFJS.getDocument = function getDocument(src,
|
function getDocument(src, pdfDataRangeTransport,
|
||||||
pdfDataRangeTransport,
|
passwordCallback, progressCallback) {
|
||||||
passwordCallback,
|
|
||||||
progressCallback) {
|
|
||||||
var task = new PDFDocumentLoadingTask();
|
var task = new PDFDocumentLoadingTask();
|
||||||
|
|
||||||
// Support of the obsolete arguments (for compatibility with API v1.0)
|
// Support of the obsolete arguments (for compatibility with API v1.0)
|
||||||
@ -413,7 +238,7 @@ PDFJS.getDocument = function getDocument(src,
|
|||||||
}).catch(task._capability.reject);
|
}).catch(task._capability.reject);
|
||||||
|
|
||||||
return task;
|
return task;
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts fetching of specified PDF document/data.
|
* Starts fetching of specified PDF document/data.
|
||||||
@ -430,8 +255,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
return Promise.reject(new Error('Worker was destroyed'));
|
return Promise.reject(new Error('Worker was destroyed'));
|
||||||
}
|
}
|
||||||
|
|
||||||
source.disableAutoFetch = PDFJS.disableAutoFetch;
|
source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
|
||||||
source.disableStream = PDFJS.disableStream;
|
source.disableStream = getDefaultSetting('disableStream');
|
||||||
source.chunkedViewerLoading = !!pdfDataRangeTransport;
|
source.chunkedViewerLoading = !!pdfDataRangeTransport;
|
||||||
if (pdfDataRangeTransport) {
|
if (pdfDataRangeTransport) {
|
||||||
source.length = pdfDataRangeTransport.length;
|
source.length = pdfDataRangeTransport.length;
|
||||||
@ -440,13 +265,14 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
||||||
docId: docId,
|
docId: docId,
|
||||||
source: source,
|
source: source,
|
||||||
disableRange: PDFJS.disableRange,
|
disableRange: getDefaultSetting('disableRange'),
|
||||||
maxImageSize: PDFJS.maxImageSize,
|
maxImageSize: getDefaultSetting('maxImageSize'),
|
||||||
cMapUrl: PDFJS.cMapUrl,
|
cMapUrl: getDefaultSetting('cMapUrl'),
|
||||||
cMapPacked: PDFJS.cMapPacked,
|
cMapPacked: getDefaultSetting('cMapPacked'),
|
||||||
disableFontFace: PDFJS.disableFontFace,
|
disableFontFace: getDefaultSetting('disableFontFace'),
|
||||||
disableCreateObjectURL: PDFJS.disableCreateObjectURL,
|
disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
|
||||||
postMessageTransfers: PDFJS.postMessageTransfers,
|
postMessageTransfers: getDefaultSetting('postMessageTransfers') &&
|
||||||
|
!isPostMessageTransfersDisabled,
|
||||||
}).then(function (workerId) {
|
}).then(function (workerId) {
|
||||||
if (worker.destroyed) {
|
if (worker.destroyed) {
|
||||||
throw new Error('Worker was destroyed');
|
throw new Error('Worker was destroyed');
|
||||||
@ -497,7 +323,7 @@ var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback to when unsupported feature is used. The callback receives
|
* Callback to when unsupported feature is used. The callback receives
|
||||||
* an {PDFJS.UNSUPPORTED_FEATURES} argument.
|
* an {UNSUPPORTED_FEATURES} argument.
|
||||||
*/
|
*/
|
||||||
this.onUnsupportedFeature = null;
|
this.onUnsupportedFeature = null;
|
||||||
}
|
}
|
||||||
@ -549,7 +375,7 @@ var PDFDocumentLoadingTask = (function PDFDocumentLoadingTaskClosure() {
|
|||||||
/**
|
/**
|
||||||
* Abstract class to support range requests file loading.
|
* Abstract class to support range requests file loading.
|
||||||
* @class
|
* @class
|
||||||
* @alias PDFJS.PDFDataRangeTransport
|
* @alias PDFDataRangeTransport
|
||||||
* @param {number} length
|
* @param {number} length
|
||||||
* @param {Uint8Array} initialData
|
* @param {Uint8Array} initialData
|
||||||
*/
|
*/
|
||||||
@ -621,8 +447,6 @@ var PDFDataRangeTransport = (function pdfDataRangeTransportClosure() {
|
|||||||
return PDFDataRangeTransport;
|
return PDFDataRangeTransport;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
PDFJS.PDFDataRangeTransport = PDFDataRangeTransport;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used
|
* Proxy to a PDFDocument in the worker thread. Also, contains commonly used
|
||||||
* properties that can be read synchronously.
|
* properties that can be read synchronously.
|
||||||
@ -825,7 +649,7 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
|
|||||||
*
|
*
|
||||||
* @typedef {Object} RenderParameters
|
* @typedef {Object} RenderParameters
|
||||||
* @property {Object} canvasContext - A 2D context of a DOM Canvas object.
|
* @property {Object} canvasContext - A 2D context of a DOM Canvas object.
|
||||||
* @property {PDFJS.PageViewport} viewport - Rendering viewport obtained by
|
* @property {PageViewport} viewport - Rendering viewport obtained by
|
||||||
* calling of PDFPage.getViewport method.
|
* calling of PDFPage.getViewport method.
|
||||||
* @property {string} intent - Rendering intent, can be 'display' or 'print'
|
* @property {string} intent - Rendering intent, can be 'display' or 'print'
|
||||||
* (default value is 'display').
|
* (default value is 'display').
|
||||||
@ -859,7 +683,7 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
this.pageInfo = pageInfo;
|
this.pageInfo = pageInfo;
|
||||||
this.transport = transport;
|
this.transport = transport;
|
||||||
this.stats = new StatTimer();
|
this.stats = new StatTimer();
|
||||||
this.stats.enabled = !!globalScope.PDFJS.enableStats;
|
this.stats.enabled = getDefaultSetting('enableStats');
|
||||||
this.commonObjs = transport.commonObjs;
|
this.commonObjs = transport.commonObjs;
|
||||||
this.objs = new PDFObjects();
|
this.objs = new PDFObjects();
|
||||||
this.cleanupAfterRender = false;
|
this.cleanupAfterRender = false;
|
||||||
@ -898,14 +722,14 @@ var PDFPageProxy = (function PDFPageProxyClosure() {
|
|||||||
* @param {number} scale The desired scale of the viewport.
|
* @param {number} scale The desired scale of the viewport.
|
||||||
* @param {number} rotate Degrees to rotate the viewport. If omitted this
|
* @param {number} rotate Degrees to rotate the viewport. If omitted this
|
||||||
* defaults to the page rotation.
|
* defaults to the page rotation.
|
||||||
* @return {PDFJS.PageViewport} Contains 'width' and 'height' properties
|
* @return {PageViewport} Contains 'width' and 'height' properties
|
||||||
* along with transforms required for rendering.
|
* along with transforms required for rendering.
|
||||||
*/
|
*/
|
||||||
getViewport: function PDFPageProxy_getViewport(scale, rotate) {
|
getViewport: function PDFPageProxy_getViewport(scale, rotate) {
|
||||||
if (arguments.length < 2) {
|
if (arguments.length < 2) {
|
||||||
rotate = this.rotate;
|
rotate = this.rotate;
|
||||||
}
|
}
|
||||||
return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0);
|
return new PageViewport(this.view, scale, rotate, 0, 0);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @param {GetAnnotationsParameters} params - Annotation parameters.
|
* @param {GetAnnotationsParameters} params - Annotation parameters.
|
||||||
@ -1193,8 +1017,11 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
var nextFakeWorkerId = 0;
|
var nextFakeWorkerId = 0;
|
||||||
|
|
||||||
function getWorkerSrc() {
|
function getWorkerSrc() {
|
||||||
if (PDFJS.workerSrc) {
|
if (typeof workerSrc !== 'undefined') {
|
||||||
return PDFJS.workerSrc;
|
return workerSrc;
|
||||||
|
}
|
||||||
|
if (getDefaultSetting('workerSrc')) {
|
||||||
|
return getDefaultSetting('workerSrc');
|
||||||
}
|
}
|
||||||
//#if PRODUCTION && !(MOZCENTRAL || FIREFOX)
|
//#if PRODUCTION && !(MOZCENTRAL || FIREFOX)
|
||||||
// if (pdfjsFilePath) {
|
// if (pdfjsFilePath) {
|
||||||
@ -1284,7 +1111,8 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
// Right now, the requirement is, that an Uint8Array is still an
|
// Right now, the requirement is, that an Uint8Array is still an
|
||||||
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
|
// Uint8Array as it arrives on the worker. (Chrome added this with v.15.)
|
||||||
//#if !SINGLE_FILE
|
//#if !SINGLE_FILE
|
||||||
if (!globalScope.PDFJS.disableWorker && typeof Worker !== 'undefined') {
|
if (!isWorkerDisabled && !getDefaultSetting('disableWorker') &&
|
||||||
|
typeof Worker !== 'undefined') {
|
||||||
var workerSrc = getWorkerSrc();
|
var workerSrc = getWorkerSrc();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -1334,10 +1162,10 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
this._port = worker;
|
this._port = worker;
|
||||||
this._webWorker = worker;
|
this._webWorker = worker;
|
||||||
if (!data.supportTransfers) {
|
if (!data.supportTransfers) {
|
||||||
PDFJS.postMessageTransfers = false;
|
isPostMessageTransfersDisabled = true;
|
||||||
}
|
}
|
||||||
this._readyCapability.resolve();
|
this._readyCapability.resolve();
|
||||||
// Send global PDFJS setting, e.g. verbosity level.
|
// Send global setting, e.g. verbosity level.
|
||||||
messageHandler.send('configure', {
|
messageHandler.send('configure', {
|
||||||
verbosity: getVerbosityLevel()
|
verbosity: getVerbosityLevel()
|
||||||
});
|
});
|
||||||
@ -1370,8 +1198,10 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
var sendTest = function () {
|
var sendTest = function () {
|
||||||
var testObj = new Uint8Array(
|
var postMessageTransfers =
|
||||||
[PDFJS.postMessageTransfers ? 255 : 0]);
|
getDefaultSetting('postMessageTransfers') &&
|
||||||
|
!isPostMessageTransfersDisabled;
|
||||||
|
var testObj = new Uint8Array([postMessageTransfers ? 255 : 0]);
|
||||||
// Some versions of Opera throw a DATA_CLONE_ERR on serializing the
|
// Some versions of Opera throw a DATA_CLONE_ERR on serializing the
|
||||||
// typed array. Also, checking if we can use transfers.
|
// typed array. Also, checking if we can use transfers.
|
||||||
try {
|
try {
|
||||||
@ -1400,9 +1230,9 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_setupFakeWorker: function PDFWorker_setupFakeWorker() {
|
_setupFakeWorker: function PDFWorker_setupFakeWorker() {
|
||||||
if (!globalScope.PDFJS.disableWorker) {
|
if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
|
||||||
warn('Setting up fake worker.');
|
warn('Setting up fake worker.');
|
||||||
globalScope.PDFJS.disableWorker = true;
|
isWorkerDisabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
|
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
|
||||||
@ -1465,7 +1295,6 @@ var PDFWorker = (function PDFWorkerClosure() {
|
|||||||
|
|
||||||
return PDFWorker;
|
return PDFWorker;
|
||||||
})();
|
})();
|
||||||
PDFJS.PDFWorker = PDFWorker;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For internal use only.
|
* For internal use only.
|
||||||
@ -1665,7 +1494,20 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
this.commonObjs.resolve(id, error);
|
this.commonObjs.resolve(id, error);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
font = new FontFaceObject(exportedData);
|
var fontRegistry = null;
|
||||||
|
if (getDefaultSetting('pdfBug') && globalScope.FontInspector &&
|
||||||
|
globalScope['FontInspector'].enabled) {
|
||||||
|
fontRegistry = {
|
||||||
|
registerFont: function (font, url) {
|
||||||
|
globalScope['FontInspector'].fontAdded(font, url);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
font = new FontFaceObject(exportedData, {
|
||||||
|
isEvalSuported: getDefaultSetting('isEvalSupported'),
|
||||||
|
disableFontFace: getDefaultSetting('disableFontFace'),
|
||||||
|
fontRegistry: fontRegistry
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fontLoader.bind(
|
this.fontLoader.bind(
|
||||||
@ -1765,7 +1607,7 @@ var WorkerTransport = (function WorkerTransportClosure() {
|
|||||||
if (loadingTask.onUnsupportedFeature) {
|
if (loadingTask.onUnsupportedFeature) {
|
||||||
loadingTask.onUnsupportedFeature(featureId);
|
loadingTask.onUnsupportedFeature(featureId);
|
||||||
}
|
}
|
||||||
PDFJS.UnsupportedManager.notify(featureId);
|
_UnsupportedManager.notify(featureId);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
messageHandler.on('JpegDecode', function(data) {
|
messageHandler.on('JpegDecode', function(data) {
|
||||||
@ -2104,7 +1946,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||||||
if (this.cancelled) {
|
if (this.cancelled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PDFJS.pdfBug && 'StepperManager' in globalScope &&
|
if (getDefaultSetting('pdfBug') && globalScope.StepperManager &&
|
||||||
globalScope.StepperManager.enabled) {
|
globalScope.StepperManager.enabled) {
|
||||||
this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
|
this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
|
||||||
this.stepper.init(this.operatorList);
|
this.stepper.init(this.operatorList);
|
||||||
@ -2160,7 +2002,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_scheduleNext: function InternalRenderTask__scheduleNext() {
|
_scheduleNext: function InternalRenderTask__scheduleNext() {
|
||||||
if (this.useRequestAnimationFrame) {
|
if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
|
||||||
window.requestAnimationFrame(this._nextBound);
|
window.requestAnimationFrame(this._nextBound);
|
||||||
} else {
|
} else {
|
||||||
Promise.resolve(undefined).then(this._nextBound);
|
Promise.resolve(undefined).then(this._nextBound);
|
||||||
@ -2193,7 +2035,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
|
|||||||
* (Deprecated) Global observer of unsupported feature usages. Use
|
* (Deprecated) Global observer of unsupported feature usages. Use
|
||||||
* onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
|
* onUnsupportedFeature callback of the {PDFDocumentLoadingTask} instance.
|
||||||
*/
|
*/
|
||||||
PDFJS.UnsupportedManager = (function UnsupportedManagerClosure() {
|
var _UnsupportedManager = (function UnsupportedManagerClosure() {
|
||||||
var listeners = [];
|
var listeners = [];
|
||||||
return {
|
return {
|
||||||
listen: function (cb) {
|
listen: function (cb) {
|
||||||
@ -2209,8 +2051,17 @@ PDFJS.UnsupportedManager = (function UnsupportedManagerClosure() {
|
|||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
exports.getDocument = PDFJS.getDocument;
|
if (typeof pdfjsVersion !== 'undefined') {
|
||||||
|
exports.version = pdfjsVersion;
|
||||||
|
}
|
||||||
|
if (typeof pdfjsBuild !== 'undefined') {
|
||||||
|
exports.build = pdfjsBuild;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.getDocument = getDocument;
|
||||||
exports.PDFDataRangeTransport = PDFDataRangeTransport;
|
exports.PDFDataRangeTransport = PDFDataRangeTransport;
|
||||||
|
exports.PDFWorker = PDFWorker;
|
||||||
exports.PDFDocumentProxy = PDFDocumentProxy;
|
exports.PDFDocumentProxy = PDFDocumentProxy;
|
||||||
exports.PDFPageProxy = PDFPageProxy;
|
exports.PDFPageProxy = PDFPageProxy;
|
||||||
|
exports._UnsupportedManager = _UnsupportedManager;
|
||||||
}));
|
}));
|
||||||
|
@ -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, ImageData */
|
/* globals ImageData */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -43,12 +43,14 @@ var assert = sharedUtil.assert;
|
|||||||
var info = sharedUtil.info;
|
var info = sharedUtil.info;
|
||||||
var isNum = sharedUtil.isNum;
|
var isNum = sharedUtil.isNum;
|
||||||
var isArray = sharedUtil.isArray;
|
var isArray = sharedUtil.isArray;
|
||||||
|
var isLittleEndian = sharedUtil.isLittleEndian;
|
||||||
var error = sharedUtil.error;
|
var error = sharedUtil.error;
|
||||||
var shadow = sharedUtil.shadow;
|
var shadow = sharedUtil.shadow;
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
var TilingPattern = displayPatternHelper.TilingPattern;
|
var TilingPattern = displayPatternHelper.TilingPattern;
|
||||||
var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
|
var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
|
||||||
var WebGLUtils = displayWebGL.WebGLUtils;
|
var WebGLUtils = displayWebGL.WebGLUtils;
|
||||||
|
var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
|
||||||
|
|
||||||
// <canvas> contexts store most of the state we need natively.
|
// <canvas> contexts store most of the state we need natively.
|
||||||
// However, PDF needs a bit more state, which we store here.
|
// However, PDF needs a bit more state, which we store here.
|
||||||
@ -67,6 +69,18 @@ var MAX_SIZE_TO_COMPILE = 1000;
|
|||||||
|
|
||||||
var FULL_CHUNK_HEIGHT = 16;
|
var FULL_CHUNK_HEIGHT = 16;
|
||||||
|
|
||||||
|
var HasCanvasTypedArraysCached = {
|
||||||
|
get value() {
|
||||||
|
return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var IsLittleEndianCached = {
|
||||||
|
get value() {
|
||||||
|
return shadow(IsLittleEndianCached, 'value', isLittleEndian());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function createScratchCanvas(width, height) {
|
function createScratchCanvas(width, height) {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
canvas.width = width;
|
canvas.width = width;
|
||||||
@ -505,13 +519,13 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
|
|||||||
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
|
if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
|
||||||
// Grayscale, 1 bit per pixel (i.e. black-and-white).
|
// Grayscale, 1 bit per pixel (i.e. black-and-white).
|
||||||
var srcLength = src.byteLength;
|
var srcLength = src.byteLength;
|
||||||
var dest32 = PDFJS.hasCanvasTypedArrays ? new Uint32Array(dest.buffer) :
|
var dest32 = HasCanvasTypedArraysCached.value ?
|
||||||
new Uint32ArrayView(dest);
|
new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
|
||||||
var dest32DataLength = dest32.length;
|
var dest32DataLength = dest32.length;
|
||||||
var fullSrcDiff = (width + 7) >> 3;
|
var fullSrcDiff = (width + 7) >> 3;
|
||||||
var white = 0xFFFFFFFF;
|
var white = 0xFFFFFFFF;
|
||||||
var black = (PDFJS.isLittleEndian || !PDFJS.hasCanvasTypedArrays) ?
|
var black = (IsLittleEndianCached.value ||
|
||||||
0xFF000000 : 0x000000FF;
|
!HasCanvasTypedArraysCached.value) ? 0xFF000000 : 0x000000FF;
|
||||||
for (i = 0; i < totalChunks; i++) {
|
for (i = 0; i < totalChunks; i++) {
|
||||||
thisChunkHeight =
|
thisChunkHeight =
|
||||||
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
(i < fullChunks) ? FULL_CHUNK_HEIGHT : partialChunkHeight;
|
||||||
|
@ -17,21 +17,17 @@
|
|||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/dom_utils', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/dom_utils', ['exports', 'pdfjs/shared/util'],
|
||||||
'pdfjs/display/global'], factory);
|
factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
factory(exports, require('../shared/util.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil);
|
||||||
root.pdfjsDisplayGlobal);
|
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
}(this, function (exports, sharedUtil) {
|
||||||
|
|
||||||
var deprecated = sharedUtil.deprecated;
|
|
||||||
var removeNullCharacters = sharedUtil.removeNullCharacters;
|
var removeNullCharacters = sharedUtil.removeNullCharacters;
|
||||||
var shadow = sharedUtil.shadow;
|
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimised CSS custom property getter/setter.
|
* Optimised CSS custom property getter/setter.
|
||||||
@ -87,10 +83,7 @@ var CustomStyle = (function CustomStyleClosure() {
|
|||||||
return CustomStyle;
|
return CustomStyle;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
PDFJS.CustomStyle = CustomStyle;
|
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||||
//// Lazy test if the userAgent support CanvasTypedArrays
|
|
||||||
function hasCanvasTypedArrays() {
|
function hasCanvasTypedArrays() {
|
||||||
var canvas = document.createElement('canvas');
|
var canvas = document.createElement('canvas');
|
||||||
canvas.width = canvas.height = 1;
|
canvas.width = canvas.height = 1;
|
||||||
@ -98,15 +91,8 @@ function hasCanvasTypedArrays() {
|
|||||||
var imageData = ctx.createImageData(1, 1);
|
var imageData = ctx.createImageData(1, 1);
|
||||||
return (typeof imageData.data.buffer !== 'undefined');
|
return (typeof imageData.data.buffer !== 'undefined');
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
|
|
||||||
configurable: true,
|
|
||||||
get: function PDFJS_hasCanvasTypedArrays() {
|
|
||||||
return shadow(PDFJS, 'hasCanvasTypedArrays', hasCanvasTypedArrays());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//#else
|
//#else
|
||||||
//PDFJS.hasCanvasTypedArrays = true;
|
//function hasCanvasTypedArrays() { return true; }
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
var LinkTarget = {
|
var LinkTarget = {
|
||||||
@ -117,8 +103,6 @@ var LinkTarget = {
|
|||||||
TOP: 4,
|
TOP: 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
PDFJS.LinkTarget = LinkTarget;
|
|
||||||
|
|
||||||
var LinkTargetStringMap = [
|
var LinkTargetStringMap = [
|
||||||
'',
|
'',
|
||||||
'_self',
|
'_self',
|
||||||
@ -127,53 +111,37 @@ var LinkTargetStringMap = [
|
|||||||
'_top'
|
'_top'
|
||||||
];
|
];
|
||||||
|
|
||||||
function isExternalLinkTargetSet() {
|
/**
|
||||||
//#if !MOZCENTRAL
|
* @typedef ExternalLinkParameters
|
||||||
if (PDFJS.openExternalLinksInNewWindow) {
|
* @typedef {Object} ExternalLinkParameters
|
||||||
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
|
* @property {string} url
|
||||||
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
|
* @property {LinkTarget} target
|
||||||
if (PDFJS.externalLinkTarget === LinkTarget.NONE) {
|
* @property {string} rel
|
||||||
PDFJS.externalLinkTarget = LinkTarget.BLANK;
|
*/
|
||||||
}
|
|
||||||
// Reset the deprecated parameter, to suppress further warnings.
|
|
||||||
PDFJS.openExternalLinksInNewWindow = false;
|
|
||||||
}
|
|
||||||
//#endif
|
|
||||||
switch (PDFJS.externalLinkTarget) {
|
|
||||||
case LinkTarget.NONE:
|
|
||||||
return false;
|
|
||||||
case LinkTarget.SELF:
|
|
||||||
case LinkTarget.BLANK:
|
|
||||||
case LinkTarget.PARENT:
|
|
||||||
case LinkTarget.TOP:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
warn('PDFJS.externalLinkTarget is invalid: ' + PDFJS.externalLinkTarget);
|
|
||||||
// Reset the external link target, to suppress further warnings.
|
|
||||||
PDFJS.externalLinkTarget = LinkTarget.NONE;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
PDFJS.isExternalLinkTargetSet = isExternalLinkTargetSet;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds various attributes (href, title, target, rel) to hyperlinks.
|
* Adds various attributes (href, title, target, rel) to hyperlinks.
|
||||||
* @param {HTMLLinkElement} link - The link element.
|
* @param {HTMLLinkElement} link - The link element.
|
||||||
* @param {Object} params - An object with the properties:
|
* @param {ExternalLinkParameters} params - An object with the properties.
|
||||||
* @param {string} params.url - An absolute URL.
|
|
||||||
*/
|
*/
|
||||||
function addLinkAttributes(link, params) {
|
function addLinkAttributes(link, params) {
|
||||||
var url = params && params.url;
|
var url = params && params.url;
|
||||||
link.href = link.title = (url ? removeNullCharacters(url) : '');
|
link.href = link.title = (url ? removeNullCharacters(url) : '');
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
if (isExternalLinkTargetSet()) {
|
var target = params.target;
|
||||||
link.target = LinkTargetStringMap[PDFJS.externalLinkTarget];
|
if (typeof target === 'undefined') {
|
||||||
|
target = getDefaultSetting('externalLinkTarget');
|
||||||
}
|
}
|
||||||
|
link.target = LinkTargetStringMap[target];
|
||||||
// Strip referrer from the URL.
|
// Strip referrer from the URL.
|
||||||
link.rel = PDFJS.externalLinkRel;
|
var rel = params.rel;
|
||||||
|
if (typeof rel === 'undefined') {
|
||||||
|
rel = getDefaultSetting('externalLinkRel');
|
||||||
|
}
|
||||||
|
link.rel = rel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PDFJS.addLinkAttributes = addLinkAttributes;
|
|
||||||
|
|
||||||
// Gets the file name from a given URL.
|
// Gets the file name from a given URL.
|
||||||
function getFilenameFromUrl(url) {
|
function getFilenameFromUrl(url) {
|
||||||
@ -184,11 +152,86 @@ function getFilenameFromUrl(url) {
|
|||||||
query > 0 ? query : url.length);
|
query > 0 ? query : url.length);
|
||||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||||
}
|
}
|
||||||
PDFJS.getFilenameFromUrl = getFilenameFromUrl;
|
|
||||||
|
function getDefaultSetting(id) {
|
||||||
|
// The list of the settings and their default is maintained for backward
|
||||||
|
// compatibility and shall not be extended or modified. See also global.js.
|
||||||
|
var globalSettings = sharedUtil.globalScope.PDFJS;
|
||||||
|
switch (id) {
|
||||||
|
case 'pdfBug':
|
||||||
|
return globalSettings ? globalSettings.pdfBug : false;
|
||||||
|
case 'disableAutoFetch':
|
||||||
|
return globalSettings ? globalSettings.disableAutoFetch : false;
|
||||||
|
case 'disableStream':
|
||||||
|
return globalSettings ? globalSettings.disableStream : false;
|
||||||
|
case 'disableRange':
|
||||||
|
return globalSettings ? globalSettings.disableRange : false;
|
||||||
|
case 'disableFontFace':
|
||||||
|
return globalSettings ? globalSettings.disableFontFace : false;
|
||||||
|
case 'disableCreateObjectURL':
|
||||||
|
return globalSettings ? globalSettings.disableCreateObjectURL : false;
|
||||||
|
case 'disableWebGL':
|
||||||
|
return globalSettings ? globalSettings.disableWebGL : true;
|
||||||
|
case 'cMapUrl':
|
||||||
|
return globalSettings ? globalSettings.cMapUrl : null;
|
||||||
|
case 'cMapPacked':
|
||||||
|
return globalSettings ? globalSettings.cMapPacked : false;
|
||||||
|
case 'postMessageTransfers':
|
||||||
|
return globalSettings ? globalSettings.postMessageTransfers : true;
|
||||||
|
case 'workerSrc':
|
||||||
|
return globalSettings ? globalSettings.workerSrc : null;
|
||||||
|
case 'disableWorker':
|
||||||
|
return globalSettings ? globalSettings.disableWorker : false;
|
||||||
|
case 'maxImageSize':
|
||||||
|
return globalSettings ? globalSettings.maxImageSize : -1;
|
||||||
|
case 'imageResourcesPath':
|
||||||
|
return globalSettings ? globalSettings.imageResourcesPath : '';
|
||||||
|
case 'isEvalSupported':
|
||||||
|
return globalSettings ? globalSettings.isEvalSupported : true;
|
||||||
|
case 'externalLinkTarget':
|
||||||
|
if (!globalSettings) {
|
||||||
|
return LinkTarget.NONE;
|
||||||
|
}
|
||||||
|
switch (globalSettings.externalLinkTarget) {
|
||||||
|
case LinkTarget.NONE:
|
||||||
|
case LinkTarget.SELF:
|
||||||
|
case LinkTarget.BLANK:
|
||||||
|
case LinkTarget.PARENT:
|
||||||
|
case LinkTarget.TOP:
|
||||||
|
return globalSettings.externalLinkTarget;
|
||||||
|
}
|
||||||
|
warn('PDFJS.externalLinkTarget is invalid: ' +
|
||||||
|
globalSettings.externalLinkTarget);
|
||||||
|
// Reset the external link target, to suppress further warnings.
|
||||||
|
globalSettings.externalLinkTarget = LinkTarget.NONE;
|
||||||
|
return LinkTarget.NONE;
|
||||||
|
case 'externalLinkRel':
|
||||||
|
return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
|
||||||
|
case 'enableStats':
|
||||||
|
return !!(globalSettings && globalSettings.enableStats);
|
||||||
|
default:
|
||||||
|
throw new Error('Unknown default setting: ' + id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isExternalLinkTargetSet() {
|
||||||
|
var externalLinkTarget = getDefaultSetting('externalLinkTarget');
|
||||||
|
switch (externalLinkTarget) {
|
||||||
|
case LinkTarget.NONE:
|
||||||
|
return false;
|
||||||
|
case LinkTarget.SELF:
|
||||||
|
case LinkTarget.BLANK:
|
||||||
|
case LinkTarget.PARENT:
|
||||||
|
case LinkTarget.TOP:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
exports.CustomStyle = CustomStyle;
|
exports.CustomStyle = CustomStyle;
|
||||||
exports.addLinkAttributes = addLinkAttributes;
|
exports.addLinkAttributes = addLinkAttributes;
|
||||||
exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
|
exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
|
||||||
exports.getFilenameFromUrl = getFilenameFromUrl;
|
exports.getFilenameFromUrl = getFilenameFromUrl;
|
||||||
exports.LinkTarget = LinkTarget;
|
exports.LinkTarget = LinkTarget;
|
||||||
|
exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
|
||||||
|
exports.getDefaultSetting = getDefaultSetting;
|
||||||
}));
|
}));
|
||||||
|
@ -18,15 +18,14 @@
|
|||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/font_loader', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/font_loader', ['exports', 'pdfjs/shared/util'],
|
||||||
'pdfjs/display/global'], factory);
|
factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
factory(exports, require('../shared/util.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil);
|
||||||
root.pdfjsDisplayGlobal);
|
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
}(this, function (exports, sharedUtil) {
|
||||||
|
|
||||||
var assert = sharedUtil.assert;
|
var assert = sharedUtil.assert;
|
||||||
var bytesToString = sharedUtil.bytesToString;
|
var bytesToString = sharedUtil.bytesToString;
|
||||||
@ -34,10 +33,6 @@ var string32 = sharedUtil.string32;
|
|||||||
var shadow = sharedUtil.shadow;
|
var shadow = sharedUtil.shadow;
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
|
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
|
||||||
var globalScope = displayGlobal.globalScope;
|
|
||||||
var isWorker = displayGlobal.isWorker;
|
|
||||||
|
|
||||||
function FontLoader(docId) {
|
function FontLoader(docId) {
|
||||||
this.docId = docId;
|
this.docId = docId;
|
||||||
this.styleElement = null;
|
this.styleElement = null;
|
||||||
@ -113,8 +108,6 @@ FontLoader.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
bind: function fontLoaderBind(fonts, callback) {
|
bind: function fontLoaderBind(fonts, callback) {
|
||||||
assert(!isWorker, 'bind() shall be called from main thread');
|
|
||||||
|
|
||||||
var rules = [];
|
var rules = [];
|
||||||
var fontsToLoad = [];
|
var fontsToLoad = [];
|
||||||
var fontLoadPromises = [];
|
var fontLoadPromises = [];
|
||||||
@ -291,8 +284,6 @@ FontLoader.prototype = {
|
|||||||
}
|
}
|
||||||
//#else
|
//#else
|
||||||
//bind: function fontLoaderBind(fonts, callback) {
|
//bind: function fontLoaderBind(fonts, callback) {
|
||||||
// assert(!isWorker, 'bind() shall be called from main thread');
|
|
||||||
//
|
|
||||||
// for (var i = 0, ii = fonts.length; i < ii; i++) {
|
// for (var i = 0, ii = fonts.length; i < ii; i++) {
|
||||||
// var font = fonts[i];
|
// var font = fonts[i];
|
||||||
// if (font.attached) {
|
// if (font.attached) {
|
||||||
@ -311,25 +302,26 @@ FontLoader.prototype = {
|
|||||||
//#endif
|
//#endif
|
||||||
};
|
};
|
||||||
//#if !(MOZCENTRAL)
|
//#if !(MOZCENTRAL)
|
||||||
FontLoader.isFontLoadingAPISupported = (!isWorker &&
|
FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' &&
|
||||||
typeof document !== 'undefined' && !!document.fonts);
|
!!document.fonts;
|
||||||
//#endif
|
//#endif
|
||||||
//#if !(MOZCENTRAL || CHROME)
|
//#if !(MOZCENTRAL || CHROME)
|
||||||
Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
|
Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
|
||||||
get: function () {
|
get: function () {
|
||||||
|
if (typeof navigator === 'undefined') {
|
||||||
|
// node.js - we can pretend sync font loading is supported.
|
||||||
|
return shadow(FontLoader, 'isSyncFontLoadingSupported', true);
|
||||||
|
}
|
||||||
|
|
||||||
var supported = false;
|
var supported = false;
|
||||||
|
|
||||||
// User agent string sniffing is bad, but there is no reliable way to tell
|
// User agent string sniffing is bad, but there is no reliable way to tell
|
||||||
// if font is fully loaded and ready to be used with canvas.
|
// if font is fully loaded and ready to be used with canvas.
|
||||||
var userAgent = window.navigator.userAgent;
|
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
|
||||||
var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(userAgent);
|
|
||||||
if (m && m[1] >= 14) {
|
if (m && m[1] >= 14) {
|
||||||
supported = true;
|
supported = true;
|
||||||
}
|
}
|
||||||
// TODO other browsers
|
// TODO other browsers
|
||||||
if (userAgent === 'node') {
|
|
||||||
supported = true;
|
|
||||||
}
|
|
||||||
return shadow(FontLoader, 'isSyncFontLoadingSupported', supported);
|
return shadow(FontLoader, 'isSyncFontLoadingSupported', supported);
|
||||||
},
|
},
|
||||||
enumerable: true,
|
enumerable: true,
|
||||||
@ -337,29 +329,21 @@ Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
|
|||||||
});
|
});
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
var IsEvalSupportedCached = {
|
||||||
|
get value() {
|
||||||
|
return shadow(this, 'value', sharedUtil.isEvalSupported());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var FontFaceObject = (function FontFaceObjectClosure() {
|
var FontFaceObject = (function FontFaceObjectClosure() {
|
||||||
function FontFaceObject(translatedData) {
|
function FontFaceObject(translatedData, options) {
|
||||||
this.compiledGlyphs = Object.create(null);
|
this.compiledGlyphs = Object.create(null);
|
||||||
// importing translated data
|
// importing translated data
|
||||||
for (var i in translatedData) {
|
for (var i in translatedData) {
|
||||||
this[i] = translatedData[i];
|
this[i] = translatedData[i];
|
||||||
}
|
}
|
||||||
|
this.options = options;
|
||||||
}
|
}
|
||||||
Object.defineProperty(FontFaceObject, 'isEvalSupported', {
|
|
||||||
get: function () {
|
|
||||||
var evalSupport = false;
|
|
||||||
if (PDFJS.isEvalSupported) {
|
|
||||||
try {
|
|
||||||
/* jshint evil: true */
|
|
||||||
new Function('');
|
|
||||||
evalSupport = true;
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
return shadow(this, 'isEvalSupported', evalSupport);
|
|
||||||
},
|
|
||||||
enumerable: true,
|
|
||||||
configurable: true
|
|
||||||
});
|
|
||||||
FontFaceObject.prototype = {
|
FontFaceObject.prototype = {
|
||||||
//#if !(MOZCENTRAL)
|
//#if !(MOZCENTRAL)
|
||||||
createNativeFontFace: function FontFaceObject_createNativeFontFace() {
|
createNativeFontFace: function FontFaceObject_createNativeFontFace() {
|
||||||
@ -367,16 +351,15 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFJS.disableFontFace) {
|
if (this.options.disableFontFace) {
|
||||||
this.disableFontFace = true;
|
this.disableFontFace = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var nativeFontFace = new FontFace(this.loadedName, this.data, {});
|
var nativeFontFace = new FontFace(this.loadedName, this.data, {});
|
||||||
|
|
||||||
if (PDFJS.pdfBug && 'FontInspector' in globalScope &&
|
if (this.options.fontRegistry) {
|
||||||
globalScope['FontInspector'].enabled) {
|
this.options.fontRegistry.registerFont(this);
|
||||||
globalScope['FontInspector'].fontAdded(this);
|
|
||||||
}
|
}
|
||||||
return nativeFontFace;
|
return nativeFontFace;
|
||||||
},
|
},
|
||||||
@ -387,7 +370,7 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDFJS.disableFontFace) {
|
if (this.options.disableFontFace) {
|
||||||
this.disableFontFace = true;
|
this.disableFontFace = true;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -396,13 +379,11 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
var fontName = this.loadedName;
|
var fontName = this.loadedName;
|
||||||
|
|
||||||
// Add the font-face rule to the document
|
// Add the font-face rule to the document
|
||||||
var url = ('url(data:' + this.mimetype + ';base64,' +
|
var url = ('url(data:' + this.mimetype + ';base64,' + btoa(data) + ');');
|
||||||
window.btoa(data) + ');');
|
|
||||||
var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
|
var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
|
||||||
|
|
||||||
if (PDFJS.pdfBug && 'FontInspector' in globalScope &&
|
if (this.options.fontRegistry) {
|
||||||
globalScope['FontInspector'].enabled) {
|
this.options.fontRegistry.registerFont(this, url);
|
||||||
globalScope['FontInspector'].fontAdded(this, url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rule;
|
return rule;
|
||||||
@ -415,7 +396,7 @@ var FontFaceObject = (function FontFaceObjectClosure() {
|
|||||||
var current, i, len;
|
var current, i, len;
|
||||||
|
|
||||||
// If we can, compile cmds into JS for MAXIMUM SPEED
|
// If we can, compile cmds into JS for MAXIMUM SPEED
|
||||||
if (FontFaceObject.isEvalSupported) {
|
if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
|
||||||
var args, js = '';
|
var args, js = '';
|
||||||
for (i = 0, len = cmds.length; i < len; i++) {
|
for (i = 0, len = cmds.length; i < len; i++) {
|
||||||
current = cmds[i];
|
current = cmds[i];
|
||||||
|
@ -18,21 +18,36 @@
|
|||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/global', ['exports', 'pdfjs/shared/util'], factory);
|
define('pdfjs/display/global', ['exports', 'pdfjs/shared/util',
|
||||||
|
'pdfjs/display/dom_utils', 'pdfjs/display/api',
|
||||||
|
'pdfjs/display/annotation_layer', 'pdfjs/display/text_layer',
|
||||||
|
'pdfjs/display/metadata', 'pdfjs/display/svg'], factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'));
|
factory(exports, require('../shared/util.js'), require('./dom_utils.js'),
|
||||||
|
require('./api.js'), require('./annotation_layer.js'),
|
||||||
|
require('./text_layer.js'), require('./metadata.js'),
|
||||||
|
require('./svg.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil);
|
factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil,
|
||||||
|
root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI,
|
||||||
|
root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer,
|
||||||
|
root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil) {
|
}(this, function (exports, sharedUtil, displayDOMUtils, displayAPI,
|
||||||
|
displayAnnotationLayer, displayTextLayer, displayMetadata,
|
||||||
|
displaySVG) {
|
||||||
|
|
||||||
var globalScope = sharedUtil.globalScope;
|
var globalScope = sharedUtil.globalScope;
|
||||||
|
var deprecated = sharedUtil.deprecated;
|
||||||
|
var warn = sharedUtil.warn;
|
||||||
|
var LinkTarget = displayDOMUtils.LinkTarget;
|
||||||
|
|
||||||
var isWorker = (typeof window === 'undefined');
|
var isWorker = (typeof window === 'undefined');
|
||||||
|
|
||||||
// The global PDFJS object exposes the API
|
// The global PDFJS object is now deprecated and will not be supported in
|
||||||
// In production, it will be declared outside a global wrapper
|
// the future. The members below are maintained for backward compatibility
|
||||||
// In development, it will be declared here
|
// and shall not be extended or modified. If the global.js is included as
|
||||||
|
// a module, we will create a global PDFJS object instance or use existing.
|
||||||
if (!globalScope.PDFJS) {
|
if (!globalScope.PDFJS) {
|
||||||
globalScope.PDFJS = {};
|
globalScope.PDFJS = {};
|
||||||
}
|
}
|
||||||
@ -86,6 +101,209 @@
|
|||||||
PDFJS.PageViewport = sharedUtil.PageViewport;
|
PDFJS.PageViewport = sharedUtil.PageViewport;
|
||||||
PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
|
PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum allowed image size in total pixels e.g. width * height. Images
|
||||||
|
* above this value will not be drawn. Use -1 for no limit.
|
||||||
|
* @var {number}
|
||||||
|
*/
|
||||||
|
PDFJS.maxImageSize = (PDFJS.maxImageSize === undefined ?
|
||||||
|
-1 : PDFJS.maxImageSize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The url of where the predefined Adobe CMaps are located. Include trailing
|
||||||
|
* slash.
|
||||||
|
* @var {string}
|
||||||
|
*/
|
||||||
|
PDFJS.cMapUrl = (PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies if CMaps are binary packed.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default fonts are converted to OpenType fonts and loaded via font face
|
||||||
|
* rules. If disabled, the font will be rendered using a built in font
|
||||||
|
* renderer that constructs the glyphs with primitive path commands.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableFontFace = (PDFJS.disableFontFace === undefined ?
|
||||||
|
false : PDFJS.disableFontFace);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path for image resources, mainly for annotation icons. Include trailing
|
||||||
|
* slash.
|
||||||
|
* @var {string}
|
||||||
|
*/
|
||||||
|
PDFJS.imageResourcesPath = (PDFJS.imageResourcesPath === undefined ?
|
||||||
|
'' : PDFJS.imageResourcesPath);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable the web worker and run all code on the main thread. This will
|
||||||
|
* happen automatically if the browser doesn't support workers or sending
|
||||||
|
* typed arrays to workers.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableWorker = (PDFJS.disableWorker === undefined ?
|
||||||
|
false : PDFJS.disableWorker);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Path and filename of the worker file. Required when the worker is enabled
|
||||||
|
* in development mode. If unspecified in the production build, the worker
|
||||||
|
* will be loaded based on the location of the pdf.js file. It is recommended
|
||||||
|
* that the workerSrc is set in a custom application to prevent issues caused
|
||||||
|
* by third-party frameworks and libraries.
|
||||||
|
* @var {string}
|
||||||
|
*/
|
||||||
|
PDFJS.workerSrc = (PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable range request loading of PDF files. When enabled and if the server
|
||||||
|
* supports partial content requests then the PDF will be fetched in chunks.
|
||||||
|
* Enabled (false) by default.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableRange = (PDFJS.disableRange === undefined ?
|
||||||
|
false : PDFJS.disableRange);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable streaming of PDF file data. By default PDF.js attempts to load PDF
|
||||||
|
* in chunks. This default behavior can be disabled.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableStream = (PDFJS.disableStream === undefined ?
|
||||||
|
false : PDFJS.disableStream);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disable pre-fetching of PDF file data. When range requests are enabled
|
||||||
|
* PDF.js will automatically keep fetching more data even if it isn't needed
|
||||||
|
* to display the current page. This default behavior can be disabled.
|
||||||
|
*
|
||||||
|
* NOTE: It is also necessary to disable streaming, see above,
|
||||||
|
* in order for disabling of pre-fetching to work correctly.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableAutoFetch = (PDFJS.disableAutoFetch === undefined ?
|
||||||
|
false : PDFJS.disableAutoFetch);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables special hooks for debugging PDF.js.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.pdfBug = (PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables transfer usage in postMessage for ArrayBuffers.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.postMessageTransfers = (PDFJS.postMessageTransfers === undefined ?
|
||||||
|
true : PDFJS.postMessageTransfers);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables URL.createObjectURL usage.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableCreateObjectURL = (PDFJS.disableCreateObjectURL === undefined ?
|
||||||
|
false : PDFJS.disableCreateObjectURL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables WebGL usage.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableWebGL = (PDFJS.disableWebGL === undefined ?
|
||||||
|
true : PDFJS.disableWebGL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the |target| attribute for external links.
|
||||||
|
* The constants from PDFJS.LinkTarget should be used:
|
||||||
|
* - NONE [default]
|
||||||
|
* - SELF
|
||||||
|
* - BLANK
|
||||||
|
* - PARENT
|
||||||
|
* - TOP
|
||||||
|
* @var {number}
|
||||||
|
*/
|
||||||
|
PDFJS.externalLinkTarget = (PDFJS.externalLinkTarget === undefined ?
|
||||||
|
LinkTarget.NONE : PDFJS.externalLinkTarget);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specifies the |rel| attribute for external links. Defaults to stripping
|
||||||
|
* the referrer.
|
||||||
|
* @var {string}
|
||||||
|
*/
|
||||||
|
PDFJS.externalLinkRel = (PDFJS.externalLinkRel === undefined ?
|
||||||
|
'noreferrer' : PDFJS.externalLinkRel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if we can eval strings as JS. Primarily used to improve
|
||||||
|
* performance for font rendering.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ?
|
||||||
|
true : PDFJS.isEvalSupported);
|
||||||
|
|
||||||
|
//#if !MOZCENTRAL
|
||||||
|
var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
|
||||||
|
delete PDFJS.openExternalLinksInNewWindow;
|
||||||
|
Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
|
||||||
|
get: function () {
|
||||||
|
return PDFJS.externalLinkTarget === LinkTarget.BLANK;
|
||||||
|
},
|
||||||
|
set: function (value) {
|
||||||
|
if (value) {
|
||||||
|
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
|
||||||
|
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
|
||||||
|
}
|
||||||
|
if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
|
||||||
|
warn('PDFJS.externalLinkTarget is already initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true
|
||||||
|
});
|
||||||
|
if (savedOpenExternalLinksInNewWindow) {
|
||||||
|
/**
|
||||||
|
* (Deprecated) Opens external links in a new window if enabled.
|
||||||
|
* The default behavior opens external links in the PDF.js window.
|
||||||
|
*
|
||||||
|
* NOTE: This property has been deprecated, please use
|
||||||
|
* `PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK` instead.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
PDFJS.getDocument = displayAPI.getDocument;
|
||||||
|
PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
|
||||||
|
PDFJS.PDFWorker = displayAPI.PDFWorker;
|
||||||
|
|
||||||
|
Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
|
||||||
|
configurable: true,
|
||||||
|
get: function PDFJS_hasCanvasTypedArrays() {
|
||||||
|
var value = displayDOMUtils.hasCanvasTypedArrays();
|
||||||
|
return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
|
||||||
|
PDFJS.LinkTarget = LinkTarget;
|
||||||
|
PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
|
||||||
|
PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
|
||||||
|
PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
|
||||||
|
|
||||||
|
PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
|
||||||
|
|
||||||
|
PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
|
||||||
|
|
||||||
|
PDFJS.Metadata = displayMetadata.Metadata;
|
||||||
|
|
||||||
|
PDFJS.SVGGraphics = displaySVG.SVGGraphics;
|
||||||
|
|
||||||
|
PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
|
||||||
|
|
||||||
exports.globalScope = globalScope;
|
exports.globalScope = globalScope;
|
||||||
exports.isWorker = isWorker;
|
exports.isWorker = isWorker;
|
||||||
exports.PDFJS = globalScope.PDFJS;
|
exports.PDFJS = globalScope.PDFJS;
|
||||||
|
@ -18,20 +18,16 @@
|
|||||||
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/metadata', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/metadata', ['exports', 'pdfjs/shared/util'], factory);
|
||||||
'pdfjs/display/global'], factory);
|
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
factory(exports, require('../shared/util.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil);
|
||||||
root.pdfjsDisplayGlobal);
|
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
}(this, function (exports, sharedUtil) {
|
||||||
|
|
||||||
var error = sharedUtil.error;
|
var error = sharedUtil.error;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
|
||||||
|
|
||||||
var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
|
||||||
function fixMetadata(meta) {
|
function fixMetadata(meta) {
|
||||||
return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
|
return meta.replace(/>\\376\\377([^<]+)/g, function(all, codes) {
|
||||||
var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
|
var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g,
|
||||||
@ -108,8 +104,5 @@ var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return Metadata;
|
|
||||||
})();
|
|
||||||
|
|
||||||
exports.Metadata = Metadata;
|
exports.Metadata = Metadata;
|
||||||
}));
|
}));
|
||||||
|
@ -15,19 +15,16 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
//#if (GENERIC || SINGLE_FILE)
|
|
||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util'], factory);
|
||||||
'pdfjs/display/global'], factory);
|
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
factory(exports, require('../shared/util.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil);
|
||||||
root.pdfjsDisplayGlobal);
|
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
}(this, function (exports, sharedUtil) {
|
||||||
|
//#if (GENERIC || SINGLE_FILE)
|
||||||
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
||||||
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
||||||
var ImageKind = sharedUtil.ImageKind;
|
var ImageKind = sharedUtil.ImageKind;
|
||||||
@ -36,7 +33,7 @@ var Util = sharedUtil.Util;
|
|||||||
var isNum = sharedUtil.isNum;
|
var isNum = sharedUtil.isNum;
|
||||||
var isArray = sharedUtil.isArray;
|
var isArray = sharedUtil.isArray;
|
||||||
var warn = sharedUtil.warn;
|
var warn = sharedUtil.warn;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
var createObjectURL = sharedUtil.createObjectURL;
|
||||||
|
|
||||||
var SVG_DEFAULTS = {
|
var SVG_DEFAULTS = {
|
||||||
fontStyle: 'normal',
|
fontStyle: 'normal',
|
||||||
@ -110,7 +107,7 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
|||||||
return (b << 16) | a;
|
return (b << 16) | a;
|
||||||
}
|
}
|
||||||
|
|
||||||
function encode(imgData, kind) {
|
function encode(imgData, kind, forceDataSchema) {
|
||||||
var width = imgData.width;
|
var width = imgData.width;
|
||||||
var height = imgData.height;
|
var height = imgData.height;
|
||||||
var bitDepth, colorType, lineSize;
|
var bitDepth, colorType, lineSize;
|
||||||
@ -226,13 +223,13 @@ var convertImgDataToPng = (function convertImgDataToPngClosure() {
|
|||||||
offset += CHUNK_WRAPPER_SIZE + idat.length;
|
offset += CHUNK_WRAPPER_SIZE + idat.length;
|
||||||
writePngChunk('IEND', new Uint8Array(0), data, offset);
|
writePngChunk('IEND', new Uint8Array(0), data, offset);
|
||||||
|
|
||||||
return PDFJS.createObjectURL(data, 'image/png');
|
return createObjectURL(data, 'image/png', forceDataSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
return function convertImgDataToPng(imgData) {
|
return function convertImgDataToPng(imgData, forceDataSchema) {
|
||||||
var kind = (imgData.kind === undefined ?
|
var kind = (imgData.kind === undefined ?
|
||||||
ImageKind.GRAYSCALE_1BPP : imgData.kind);
|
ImageKind.GRAYSCALE_1BPP : imgData.kind);
|
||||||
return encode(imgData, kind);
|
return encode(imgData, kind, forceDataSchema);
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -377,7 +374,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
function SVGGraphics(commonObjs, objs) {
|
function SVGGraphics(commonObjs, objs, forceDataSchema) {
|
||||||
this.current = new SVGExtraState();
|
this.current = new SVGExtraState();
|
||||||
this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix
|
this.transformMatrix = IDENTITY_MATRIX; // Graphics state matrix
|
||||||
this.transformStack = [];
|
this.transformStack = [];
|
||||||
@ -389,6 +386,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
this.embedFonts = false;
|
this.embedFonts = false;
|
||||||
this.embeddedFonts = Object.create(null);
|
this.embeddedFonts = Object.create(null);
|
||||||
this.cssStyle = null;
|
this.cssStyle = null;
|
||||||
|
this.forceDataSchema = !!forceDataSchema;
|
||||||
}
|
}
|
||||||
|
|
||||||
var NS = 'http://www.w3.org/2000/svg';
|
var NS = 'http://www.w3.org/2000/svg';
|
||||||
@ -453,8 +451,8 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
|
|
||||||
transform: function SVGGraphics_transform(a, b, c, d, e, f) {
|
transform: function SVGGraphics_transform(a, b, c, d, e, f) {
|
||||||
var transformMatrix = [a, b, c, d, e, f];
|
var transformMatrix = [a, b, c, d, e, f];
|
||||||
this.transformMatrix = PDFJS.Util.transform(this.transformMatrix,
|
this.transformMatrix = Util.transform(this.transformMatrix,
|
||||||
transformMatrix);
|
transformMatrix);
|
||||||
|
|
||||||
this.tgrp = document.createElementNS(NS, 'svg:g');
|
this.tgrp = document.createElementNS(NS, 'svg:g');
|
||||||
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
|
||||||
@ -777,7 +775,8 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
this.defs.appendChild(this.cssStyle);
|
this.defs.appendChild(this.cssStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = PDFJS.createObjectURL(fontObj.data, fontObj.mimetype);
|
var url = createObjectURL(fontObj.data, fontObj.mimetype,
|
||||||
|
this.forceDataSchema);
|
||||||
this.cssStyle.textContent +=
|
this.cssStyle.textContent +=
|
||||||
'@font-face { font-family: "' + fontObj.loadedName + '";' +
|
'@font-face { font-family: "' + fontObj.loadedName + '";' +
|
||||||
' src: url(' + url + '); }\n';
|
' src: url(' + url + '); }\n';
|
||||||
@ -1122,7 +1121,7 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
var width = imgData.width;
|
var width = imgData.width;
|
||||||
var height = imgData.height;
|
var height = imgData.height;
|
||||||
|
|
||||||
var imgSrc = convertImgDataToPng(imgData);
|
var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
|
||||||
var cliprect = document.createElementNS(NS, 'svg:rect');
|
var cliprect = document.createElementNS(NS, 'svg:rect');
|
||||||
cliprect.setAttributeNS(null, 'x', '0');
|
cliprect.setAttributeNS(null, 'x', '0');
|
||||||
cliprect.setAttributeNS(null, 'y', '0');
|
cliprect.setAttributeNS(null, 'y', '0');
|
||||||
@ -1208,8 +1207,6 @@ var SVGGraphics = (function SVGGraphicsClosure() {
|
|||||||
return SVGGraphics;
|
return SVGGraphics;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
PDFJS.SVGGraphics = SVGGraphics;
|
|
||||||
|
|
||||||
exports.SVGGraphics = SVGGraphics;
|
exports.SVGGraphics = SVGGraphics;
|
||||||
}));
|
|
||||||
//#endif
|
//#endif
|
||||||
|
}));
|
||||||
|
@ -18,20 +18,20 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util',
|
||||||
'pdfjs/display/dom_utils', 'pdfjs/display/global'], factory);
|
'pdfjs/display/dom_utils'], factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./dom_utils.js'),
|
factory(exports, require('../shared/util.js'), require('./dom_utils.js'));
|
||||||
require('./global.js'));
|
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil,
|
||||||
root.pdfjsDisplayDOMUtils, root.pdfjsDisplayGlobal);
|
root.pdfjsDisplayDOMUtils);
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayDOMUtils, displayGlobal) {
|
}(this, function (exports, sharedUtil, displayDOMUtils) {
|
||||||
|
|
||||||
var Util = sharedUtil.Util;
|
var Util = sharedUtil.Util;
|
||||||
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
|
var PageViewport = sharedUtil.PageViewport;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text layer render parameters.
|
* Text layer render parameters.
|
||||||
@ -40,7 +40,7 @@ var PDFJS = displayGlobal.PDFJS;
|
|||||||
* @property {TextContent} textContent - Text content to render (the object is
|
* @property {TextContent} textContent - Text content to render (the object is
|
||||||
* returned by the page's getTextContent() method).
|
* returned by the page's getTextContent() method).
|
||||||
* @property {HTMLElement} container - HTML element that will contain text runs.
|
* @property {HTMLElement} container - HTML element that will contain text runs.
|
||||||
* @property {PDFJS.PageViewport} viewport - The target viewport to properly
|
* @property {PageViewport} viewport - The target viewport to properly
|
||||||
* layout the text runs.
|
* layout the text runs.
|
||||||
* @property {Array} textDivs - (optional) HTML elements that are correspond
|
* @property {Array} textDivs - (optional) HTML elements that are correspond
|
||||||
* the text items of the textContent input. This is output and shall be
|
* the text items of the textContent input. This is output and shall be
|
||||||
@ -96,7 +96,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
// |fontName| is only used by the Font Inspector. This test will succeed
|
// |fontName| is only used by the Font Inspector. This test will succeed
|
||||||
// when e.g. the Font Inspector is off but the Stepper is on, but it's
|
// when e.g. the Font Inspector is off but the Stepper is on, but it's
|
||||||
// not worth the effort to do a more accurate test.
|
// not worth the effort to do a more accurate test.
|
||||||
if (PDFJS.pdfBug) {
|
if (getDefaultSetting('pdfBug')) {
|
||||||
textDiv.dataset.fontName = geom.fontName;
|
textDiv.dataset.fontName = geom.fontName;
|
||||||
}
|
}
|
||||||
// Storing into dataset will convert number into string.
|
// Storing into dataset will convert number into string.
|
||||||
@ -183,7 +183,7 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
*
|
*
|
||||||
* @param {TextContent} textContent
|
* @param {TextContent} textContent
|
||||||
* @param {HTMLElement} container
|
* @param {HTMLElement} container
|
||||||
* @param {PDFJS.PageViewport} viewport
|
* @param {PageViewport} viewport
|
||||||
* @param {Array} textDivs
|
* @param {Array} textDivs
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
@ -251,7 +251,5 @@ var renderTextLayer = (function renderTextLayerClosure() {
|
|||||||
return renderTextLayer;
|
return renderTextLayer;
|
||||||
})();
|
})();
|
||||||
|
|
||||||
PDFJS.renderTextLayer = renderTextLayer;
|
|
||||||
|
|
||||||
exports.renderTextLayer = renderTextLayer;
|
exports.renderTextLayer = renderTextLayer;
|
||||||
}));
|
}));
|
||||||
|
@ -19,17 +19,17 @@
|
|||||||
(function (root, factory) {
|
(function (root, factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/display/webgl', ['exports', 'pdfjs/shared/util',
|
define('pdfjs/display/webgl', ['exports', 'pdfjs/shared/util',
|
||||||
'pdfjs/display/global'], factory);
|
'pdfjs/display/dom_utils'], factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
factory(exports, require('../shared/util.js'), require('./dom_utils.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil,
|
factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil,
|
||||||
root.pdfjsDisplayGlobal);
|
root.pdfjsDisplayDOMUtils);
|
||||||
}
|
}
|
||||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
}(this, function (exports, sharedUtil, displayDOMUtils) {
|
||||||
|
|
||||||
var shadow = sharedUtil.shadow;
|
var shadow = sharedUtil.shadow;
|
||||||
var PDFJS = displayGlobal.PDFJS;
|
var getDefaultSetting = displayDOMUtils.getDefaultSetting;
|
||||||
|
|
||||||
var WebGLUtils = (function WebGLUtilsClosure() {
|
var WebGLUtils = (function WebGLUtilsClosure() {
|
||||||
function loadShader(gl, code, shaderType) {
|
function loadShader(gl, code, shaderType) {
|
||||||
@ -432,7 +432,7 @@ var WebGLUtils = (function WebGLUtilsClosure() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
get isEnabled() {
|
get isEnabled() {
|
||||||
if (PDFJS.disableWebGL) {
|
if (getDefaultSetting('disableWebGL')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var enabled = false;
|
var enabled = false;
|
||||||
|
@ -12,16 +12,17 @@
|
|||||||
* 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, require, module, requirejs */
|
/* globals require, module, requirejs,
|
||||||
|
workerSrc: true, isWorkerDisabled: true */
|
||||||
|
|
||||||
// included from api.js for GENERIC build
|
// included from api.js for GENERIC build
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var useRequireEnsure = false;
|
var useRequireEnsure = false;
|
||||||
if (typeof module !== 'undefined' && module.require) {
|
if (typeof window === 'undefined') {
|
||||||
// node.js - disable worker and set require.ensure.
|
// node.js - disable worker and set require.ensure.
|
||||||
PDFJS.disableWorker = true;
|
isWorkerDisabled = true;
|
||||||
if (typeof require.ensure === 'undefined') {
|
if (typeof require.ensure === 'undefined') {
|
||||||
require.ensure = require('node-ensure');
|
require.ensure = require('node-ensure');
|
||||||
}
|
}
|
||||||
@ -29,11 +30,11 @@ if (typeof module !== 'undefined' && module.require) {
|
|||||||
}
|
}
|
||||||
if (typeof __webpack_require__ !== 'undefined') {
|
if (typeof __webpack_require__ !== 'undefined') {
|
||||||
// Webpack - get/bundle pdf.worker.js as additional file.
|
// Webpack - get/bundle pdf.worker.js as additional file.
|
||||||
PDFJS.workerSrc = require('entry?name=[hash]-worker.js!./pdf.worker.js');
|
workerSrc = require('entry?name=[hash]-worker.js!./pdf.worker.js');
|
||||||
useRequireEnsure = true;
|
useRequireEnsure = true;
|
||||||
}
|
}
|
||||||
if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
|
if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
|
||||||
PDFJS.workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
|
workerSrc = requirejs.toUrl('pdfjs-dist/build/pdf.worker.js');
|
||||||
}
|
}
|
||||||
var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) {
|
var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) {
|
||||||
require.ensure([], function () {
|
require.ensure([], function () {
|
||||||
|
@ -19,32 +19,48 @@
|
|||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define('pdfjs/main_loader', ['exports', 'pdfjs/display/api',
|
define('pdfjs/main_loader', ['exports', 'pdfjs/display/api',
|
||||||
'pdfjs/display/annotation_layer', 'pdfjs/display/text_layer',
|
'pdfjs/display/annotation_layer', 'pdfjs/display/text_layer',
|
||||||
'pdfjs/display/dom_utils', 'pdfjs/shared/util', 'pdfjs/display/global'],
|
'pdfjs/display/dom_utils', 'pdfjs/shared/util', 'pdfjs/display/svg',
|
||||||
|
'pdfjs/display/global'],
|
||||||
factory);
|
factory);
|
||||||
} else if (typeof exports !== 'undefined') {
|
} else if (typeof exports !== 'undefined') {
|
||||||
factory(exports, require('./display/api.js'),
|
factory(exports, require('./display/api.js'),
|
||||||
require('./display/annotation_layer.js'),
|
require('./display/annotation_layer.js'),
|
||||||
require('./display/text_layer.js'), require('./display/dom_utils.js'),
|
require('./display/text_layer.js'), require('./display/dom_utils.js'),
|
||||||
require('./shared/util.js'), require('./display/global.js'));
|
require('./shared/util.js'), require('./display/svg.js'),
|
||||||
|
require('./display/global.js'));
|
||||||
} else {
|
} else {
|
||||||
factory((root.pdfjsMainLoader = {}), root.pdfjsDisplayAPI,
|
factory((root.pdfjsMainLoader = {}), root.pdfjsDisplayAPI,
|
||||||
root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer,
|
root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer,
|
||||||
root.pdfjsDisplayDOMUtils, root.pdfjsSharedUtil, root.pdfjsDisplayGlobal);
|
root.pdfjsDisplayDOMUtils, root.pdfjsSharedUtil, root.pdfjsDisplaySVG,
|
||||||
|
root.pdfjsDisplayGlobal);
|
||||||
}
|
}
|
||||||
}(this, function (exports, displayAPI, displayAnnotationLayer,
|
}(this, function (exports, displayAPI, displayAnnotationLayer,
|
||||||
displayTextLayer, displayDOMUtils, sharedUtil,
|
displayTextLayer, displayDOMUtils, sharedUtil,
|
||||||
displayGlobal) {
|
displaySVG, displayGlobal) {
|
||||||
|
|
||||||
// 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;
|
||||||
exports.PasswordResponses = sharedUtil.PasswordResponses;
|
exports.PasswordResponses = sharedUtil.PasswordResponses;
|
||||||
exports.InvalidPDFException = sharedUtil.InvalidPDFException;
|
exports.InvalidPDFException = sharedUtil.InvalidPDFException;
|
||||||
exports.MissingPDFException = sharedUtil.MissingPDFException;
|
exports.MissingPDFException = sharedUtil.MissingPDFException;
|
||||||
|
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;
|
||||||
|
|
||||||
}));
|
}));
|
||||||
|
14
src/pdf.js
14
src/pdf.js
@ -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;
|
||||||
@ -55,8 +58,19 @@
|
|||||||
exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
|
exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
|
||||||
exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
|
exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
|
||||||
exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
|
exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
|
||||||
|
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
|
||||||
|
@ -592,6 +592,17 @@ function isLittleEndian() {
|
|||||||
return (buffer16[0] === 1);
|
return (buffer16[0] === 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Checks if it's possible to eval JS expressions.
|
||||||
|
function isEvalSupported() {
|
||||||
|
try {
|
||||||
|
/* jshint evil: true */
|
||||||
|
new Function('');
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||||
var Uint32ArrayView = (function Uint32ArrayViewClosure() {
|
var Uint32ArrayView = (function Uint32ArrayViewClosure() {
|
||||||
|
|
||||||
@ -889,7 +900,7 @@ var Util = (function UtilClosure() {
|
|||||||
/**
|
/**
|
||||||
* PDF page viewport created based on scale, rotation and offset.
|
* PDF page viewport created based on scale, rotation and offset.
|
||||||
* @class
|
* @class
|
||||||
* @alias PDFJS.PageViewport
|
* @alias PageViewport
|
||||||
*/
|
*/
|
||||||
var PageViewport = (function PageViewportClosure() {
|
var PageViewport = (function PageViewportClosure() {
|
||||||
/**
|
/**
|
||||||
@ -965,13 +976,13 @@ var PageViewport = (function PageViewportClosure() {
|
|||||||
this.height = height;
|
this.height = height;
|
||||||
this.fontScale = scale;
|
this.fontScale = scale;
|
||||||
}
|
}
|
||||||
PageViewport.prototype = /** @lends PDFJS.PageViewport.prototype */ {
|
PageViewport.prototype = /** @lends PageViewport.prototype */ {
|
||||||
/**
|
/**
|
||||||
* Clones viewport with additional properties.
|
* Clones viewport with additional properties.
|
||||||
* @param args {Object} (optional) If specified, may contain the 'scale' or
|
* @param args {Object} (optional) If specified, may contain the 'scale' or
|
||||||
* 'rotation' properties to override the corresponding properties in
|
* 'rotation' properties to override the corresponding properties in
|
||||||
* the cloned viewport.
|
* the cloned viewport.
|
||||||
* @returns {PDFJS.PageViewport} Cloned viewport.
|
* @returns {PageViewport} Cloned viewport.
|
||||||
*/
|
*/
|
||||||
clone: function PageViewPort_clone(args) {
|
clone: function PageViewPort_clone(args) {
|
||||||
args = args || {};
|
args = args || {};
|
||||||
@ -1101,7 +1112,7 @@ function isArrayBuffer(v) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a promise capability object.
|
* Creates a promise capability object.
|
||||||
* @alias PDFJS.createPromiseCapability
|
* @alias createPromiseCapability
|
||||||
*
|
*
|
||||||
* @return {PromiseCapability} A capability object contains:
|
* @return {PromiseCapability} A capability object contains:
|
||||||
* - a Promise, resolve and reject methods.
|
* - a Promise, resolve and reject methods.
|
||||||
@ -2347,6 +2358,7 @@ exports.isString = isString;
|
|||||||
exports.isSameOrigin = isSameOrigin;
|
exports.isSameOrigin = isSameOrigin;
|
||||||
exports.isValidUrl = isValidUrl;
|
exports.isValidUrl = isValidUrl;
|
||||||
exports.isLittleEndian = isLittleEndian;
|
exports.isLittleEndian = isLittleEndian;
|
||||||
|
exports.isEvalSupported = isEvalSupported;
|
||||||
exports.loadJpegStream = loadJpegStream;
|
exports.loadJpegStream = loadJpegStream;
|
||||||
exports.log2 = log2;
|
exports.log2 = log2;
|
||||||
exports.readInt8 = readInt8;
|
exports.readInt8 = readInt8;
|
||||||
|
@ -33,8 +33,9 @@ limitations under the License.
|
|||||||
<script>
|
<script>
|
||||||
require.config({paths: {'pdfjs': '../src'}});
|
require.config({paths: {'pdfjs': '../src'}});
|
||||||
require(['pdfjs/display/api', 'pdfjs/display/text_layer',
|
require(['pdfjs/display/api', 'pdfjs/display/text_layer',
|
||||||
'pdfjs/display/annotation_layer', 'pdfjs/shared/util'],
|
'pdfjs/display/annotation_layer', 'pdfjs/display/global',
|
||||||
function (api, textLayer, annotationLayer, pdfjsSharedUtil) {
|
'pdfjs/shared/util'],
|
||||||
|
function (api, textLayer, annotationLayer, global, pdfjsSharedUtil) {
|
||||||
window.pdfjsSharedUtil = pdfjsSharedUtil;
|
window.pdfjsSharedUtil = pdfjsSharedUtil;
|
||||||
|
|
||||||
var driver = new Driver({
|
var driver = new Driver({
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
72
web/app.js
72
web/app.js
@ -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);
|
||||||
|
@ -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.
|
||||||
|
@ -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,
|
||||||
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
@ -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.');
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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';
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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
|
||||||
|
@ -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,
|
||||||
|
@ -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,
|
||||||
|
@ -12,6 +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.
|
||||||
*/
|
*/
|
||||||
|
/* global PDFJS */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@ -25,6 +26,61 @@ var VERTICAL_PADDING = 5;
|
|||||||
|
|
||||||
var mozL10n = document.mozL10n || document.webL10n;
|
var mozL10n = document.mozL10n || document.webL10n;
|
||||||
|
|
||||||
|
if (typeof PDFJS === 'undefined') {
|
||||||
|
(typeof window !== 'undefined' ? window : this).PDFJS = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disables fullscreen support, and by extension Presentation Mode,
|
||||||
|
* in browsers which support the fullscreen API.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ?
|
||||||
|
false : PDFJS.disableFullscreen);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables CSS only zooming.
|
||||||
|
* @var {boolean}
|
||||||
|
*/
|
||||||
|
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
|
||||||
|
false : PDFJS.useOnlyCssZoom);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximum supported canvas size in total pixels e.g. width * height.
|
||||||
|
* The default value is 4096 * 4096. Use -1 for no limit.
|
||||||
|
* @var {number}
|
||||||
|
*/
|
||||||
|
PDFJS.maxCanvasPixels = (PDFJS.maxCanvasPixels === undefined ?
|
||||||
|
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)
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user