Merge pull request #7053 from yurydelendik/rm-pdfjs-core
Removes global PDFJS usage from the src/core/.
This commit is contained in:
commit
df7afcf004
@ -17,17 +17,14 @@
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/core/bidi', ['exports', 'pdfjs/shared/global'], factory);
|
||||
define('pdfjs/core/bidi', ['exports'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/global.js'));
|
||||
factory(exports);
|
||||
} else {
|
||||
factory((root.pdfjsCoreBidi = {}), root.pdfjsSharedGlobal);
|
||||
factory((root.pdfjsCoreBidi = {}));
|
||||
}
|
||||
}(this, function (exports, sharedGlobal) {
|
||||
}(this, function (exports) {
|
||||
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
|
||||
var bidi = PDFJS.bidi = (function bidiClosure() {
|
||||
// Character types for symbols from 0000 to 00FF.
|
||||
var baseTypes = [
|
||||
'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'BN', 'S', 'B', 'S', 'WS',
|
||||
@ -430,8 +427,5 @@ var bidi = PDFJS.bidi = (function bidiClosure() {
|
||||
return createBidiText(chars.join(''), isLTR);
|
||||
}
|
||||
|
||||
return bidi;
|
||||
})();
|
||||
|
||||
exports.bidi = bidi;
|
||||
}));
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -35,7 +34,6 @@ var assert = sharedUtil.assert;
|
||||
var error = sharedUtil.error;
|
||||
var isInt = sharedUtil.isInt;
|
||||
var isString = sharedUtil.isString;
|
||||
var warn = sharedUtil.warn;
|
||||
var isName = corePrimitives.isName;
|
||||
var isCmd = corePrimitives.isCmd;
|
||||
var isStream = corePrimitives.isStream;
|
||||
|
@ -79,6 +79,7 @@ var Page = (function PageClosure() {
|
||||
this.idCounters = {
|
||||
obj: 0
|
||||
};
|
||||
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
||||
this.resourcesPromise = null;
|
||||
}
|
||||
|
||||
@ -224,7 +225,8 @@ var Page = (function PageClosure() {
|
||||
handler, this.pageIndex,
|
||||
'p' + this.pageIndex + '_',
|
||||
this.idCounters,
|
||||
this.fontCache);
|
||||
this.fontCache,
|
||||
this.evaluatorOptions);
|
||||
|
||||
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
var pageListPromise = dataPromises.then(function(data) {
|
||||
@ -289,7 +291,8 @@ var Page = (function PageClosure() {
|
||||
handler, self.pageIndex,
|
||||
'p' + self.pageIndex + '_',
|
||||
self.idCounters,
|
||||
self.fontCache);
|
||||
self.fontCache,
|
||||
self.evaluatorOptions);
|
||||
|
||||
return partialEvaluator.getTextContent(contentStream,
|
||||
task,
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -108,8 +107,15 @@ var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
|
||||
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
|
||||
|
||||
var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
var DefaultPartialEvaluatorOptions = {
|
||||
forceDataSchema: false,
|
||||
maxImageSize: -1,
|
||||
disableFontFace: false,
|
||||
cMapOptions: { url: null, packed: false }
|
||||
};
|
||||
|
||||
function PartialEvaluator(pdfManager, xref, handler, pageIndex,
|
||||
uniquePrefix, idCounters, fontCache) {
|
||||
uniquePrefix, idCounters, fontCache, options) {
|
||||
this.pdfManager = pdfManager;
|
||||
this.xref = xref;
|
||||
this.handler = handler;
|
||||
@ -117,6 +123,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
this.uniquePrefix = uniquePrefix;
|
||||
this.idCounters = idCounters;
|
||||
this.fontCache = fontCache;
|
||||
this.options = options || DefaultPartialEvaluatorOptions;
|
||||
}
|
||||
|
||||
// Trying to minimize Date.now() usage and check every 100 time
|
||||
@ -275,7 +282,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
warn('Image dimensions are missing, or not numbers.');
|
||||
return;
|
||||
}
|
||||
if (PDFJS.maxImageSize !== -1 && w * h > PDFJS.maxImageSize) {
|
||||
var maxImageSize = this.options.maxImageSize;
|
||||
if (maxImageSize !== -1 && w * h > maxImageSize) {
|
||||
warn('Image exceeded maximum allowed size and was removed.');
|
||||
return;
|
||||
}
|
||||
@ -339,11 +347,13 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
// These JPEGs don't need any more processing so we can just send it.
|
||||
operatorList.addOp(OPS.paintJpegXObject, args);
|
||||
this.handler.send('obj',
|
||||
[objId, this.pageIndex, 'JpegStream', image.getIR()]);
|
||||
[objId, this.pageIndex, 'JpegStream',
|
||||
image.getIR(this.options.forceDataSchema)]);
|
||||
return;
|
||||
}
|
||||
|
||||
PDFImage.buildImage(self.handler, self.xref, resources, image, inline).
|
||||
PDFImage.buildImage(self.handler, self.xref, resources, image, inline,
|
||||
this.options.forceDataSchema).
|
||||
then(function(imageObj) {
|
||||
var imgData = imageObj.createImageData(/* forceRGBA = */ false);
|
||||
self.handler.send('obj', [objId, self.pageIndex, 'Image', imgData],
|
||||
@ -451,7 +461,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
var glyphs = font.charsToGlyphs(chars);
|
||||
var isAddToPathSet = !!(state.textRenderingMode &
|
||||
TextRenderingMode.ADD_TO_PATH_FLAG);
|
||||
if (font.data && (isAddToPathSet || PDFJS.disableFontFace)) {
|
||||
if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
|
||||
var buildPath = function (fontChar) {
|
||||
if (!font.renderer.hasBuiltPath(fontChar)) {
|
||||
var path = font.renderer.getPathJs(fontChar);
|
||||
@ -1174,7 +1184,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
|
||||
function runBidiTransform(textChunk) {
|
||||
var str = textChunk.str.join('');
|
||||
var bidiResult = PDFJS.bidi(str, -1, textChunk.vertical);
|
||||
var bidiResult = bidi(str, -1, textChunk.vertical);
|
||||
return {
|
||||
str: (normalizeWhitespace ? replaceWhitespace(bidiResult.str) :
|
||||
bidiResult.str),
|
||||
@ -1757,8 +1767,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
var ucs2CMapName = new Name(registry + '-' + ordering + '-UCS2');
|
||||
// d) Obtain the CMap with the name constructed in step (c) (available
|
||||
// from the ASN Web site; see the Bibliography).
|
||||
return CMapFactory.create(ucs2CMapName,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
|
||||
return CMapFactory.create(ucs2CMapName, this.options.cMapOptions,
|
||||
null).then(
|
||||
function (ucs2CMap) {
|
||||
var cMap = properties.cMap;
|
||||
toUnicode = [];
|
||||
@ -1785,8 +1795,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
|
||||
var cmapObj = toUnicode;
|
||||
if (isName(cmapObj)) {
|
||||
return CMapFactory.create(cmapObj,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
|
||||
return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(
|
||||
function (cmap) {
|
||||
if (cmap instanceof IdentityCMap) {
|
||||
return new IdentityToUnicodeMap(0, 0xFFFF);
|
||||
@ -1794,8 +1803,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
return new ToUnicodeMap(cmap.getMap());
|
||||
});
|
||||
} else if (isStream(cmapObj)) {
|
||||
return CMapFactory.create(cmapObj,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
|
||||
return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(
|
||||
function (cmap) {
|
||||
if (cmap instanceof IdentityCMap) {
|
||||
return new IdentityToUnicodeMap(0, 0xFFFF);
|
||||
@ -2086,6 +2094,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
var descriptor = preEvaluatedFont.descriptor;
|
||||
var type = preEvaluatedFont.type;
|
||||
var maxCharIndex = (composite ? 0xFFFF : 0xFF);
|
||||
var cMapOptions = this.options.cMapOptions;
|
||||
var properties;
|
||||
|
||||
if (!descriptor) {
|
||||
@ -2213,8 +2222,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
||||
if (isName(cidEncoding)) {
|
||||
properties.cidEncoding = cidEncoding.name;
|
||||
}
|
||||
cMapPromise = CMapFactory.create(cidEncoding,
|
||||
{ url: PDFJS.cMapUrl, packed: PDFJS.cMapPacked }, null).then(
|
||||
cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(
|
||||
function (cMap) {
|
||||
properties.cMap = cMap;
|
||||
properties.vertical = properties.cMap.vertical;
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -20,24 +19,24 @@
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/core/fonts', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/core/primitives', 'pdfjs/core/stream', 'pdfjs/core/parser',
|
||||
'pdfjs/core/cmap', 'pdfjs/core/glyphlist', 'pdfjs/core/charsets',
|
||||
'pdfjs/core/glyphlist', 'pdfjs/core/charsets',
|
||||
'pdfjs/core/font_renderer', 'pdfjs/core/encodings',
|
||||
'pdfjs/core/standard_fonts', 'pdfjs/core/unicode'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'), require('./primitives.js'),
|
||||
require('./stream.js'), require('./parser.js'), require('./cmap.js'),
|
||||
require('./stream.js'), require('./parser.js'),
|
||||
require('./glyphlist.js'), require('./charsets.js'),
|
||||
require('./font_renderer.js'), require('./encodings.js'),
|
||||
require('./standard_fonts'), require('./unicode.js'));
|
||||
} else {
|
||||
factory((root.pdfjsCoreFonts = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser,
|
||||
root.pdfjsCoreCMap, root.pdfjsCoreGlyphList, root.pdfjsCoreCharsets,
|
||||
root.pdfjsCoreGlyphList, root.pdfjsCoreCharsets,
|
||||
root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings,
|
||||
root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser,
|
||||
coreCMap, coreGlyphList, coreCharsets, coreFontRenderer,
|
||||
coreGlyphList, coreCharsets, coreFontRenderer,
|
||||
coreEncodings, coreStandardFonts, coreUnicode) {
|
||||
|
||||
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
||||
@ -55,11 +54,8 @@ var shadow = sharedUtil.shadow;
|
||||
var stringToBytes = sharedUtil.stringToBytes;
|
||||
var string32 = sharedUtil.string32;
|
||||
var warn = sharedUtil.warn;
|
||||
var Name = corePrimitives.Name;
|
||||
var Stream = coreStream.Stream;
|
||||
var Lexer = coreParser.Lexer;
|
||||
var CMapFactory = coreCMap.CMapFactory;
|
||||
var IdentityCMap = coreCMap.IdentityCMap;
|
||||
var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
|
||||
var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
|
||||
var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
|
||||
|
@ -51,7 +51,7 @@ var PDFImage = (function PDFImageClosure() {
|
||||
* Decode the image in the main thread if it supported. Resovles the promise
|
||||
* when the image data is ready.
|
||||
*/
|
||||
function handleImageData(handler, xref, res, image) {
|
||||
function handleImageData(handler, xref, res, image, forceDataSchema) {
|
||||
if (image instanceof JpegStream && image.isNativelyDecodable(xref, res)) {
|
||||
// For natively supported jpegs send them to the main thread for decoding.
|
||||
var dict = image.dict;
|
||||
@ -59,7 +59,8 @@ var PDFImage = (function PDFImageClosure() {
|
||||
colorSpace = ColorSpace.parse(colorSpace, xref, res);
|
||||
var numComps = colorSpace.numComps;
|
||||
var decodePromise = handler.sendWithPromise('JpegDecode',
|
||||
[image.getIR(), numComps]);
|
||||
[image.getIR(forceDataSchema),
|
||||
numComps]);
|
||||
return decodePromise.then(function (message) {
|
||||
var data = message.data;
|
||||
return new Stream(data, 0, data.length, image.dict);
|
||||
@ -184,8 +185,10 @@ var PDFImage = (function PDFImageClosure() {
|
||||
* with a PDFImage when the image is ready to be used.
|
||||
*/
|
||||
PDFImage.buildImage = function PDFImage_buildImage(handler, xref,
|
||||
res, image, inline) {
|
||||
var imagePromise = handleImageData(handler, xref, res, image);
|
||||
res, image, inline,
|
||||
forceDataSchema) {
|
||||
var imagePromise = handleImageData(handler, xref, res, image,
|
||||
forceDataSchema);
|
||||
var smaskPromise;
|
||||
var maskPromise;
|
||||
|
||||
@ -193,13 +196,15 @@ var PDFImage = (function PDFImageClosure() {
|
||||
var mask = image.dict.get('Mask');
|
||||
|
||||
if (smask) {
|
||||
smaskPromise = handleImageData(handler, xref, res, smask);
|
||||
smaskPromise = handleImageData(handler, xref, res, smask,
|
||||
forceDataSchema);
|
||||
maskPromise = Promise.resolve(null);
|
||||
} else {
|
||||
smaskPromise = Promise.resolve(null);
|
||||
if (mask) {
|
||||
if (isStream(mask)) {
|
||||
maskPromise = handleImageData(handler, xref, res, mask);
|
||||
maskPromise = handleImageData(handler, xref, res, mask,
|
||||
forceDataSchema);
|
||||
} else if (isArray(mask)) {
|
||||
maskPromise = Promise.resolve(mask);
|
||||
} else {
|
||||
|
@ -110,8 +110,9 @@ var BasePdfManager = (function BasePdfManagerClosure() {
|
||||
})();
|
||||
|
||||
var LocalPdfManager = (function LocalPdfManagerClosure() {
|
||||
function LocalPdfManager(docId, data, password) {
|
||||
function LocalPdfManager(docId, data, password, evaluatorOptions) {
|
||||
this._docId = docId;
|
||||
this.evaluatorOptions = evaluatorOptions;
|
||||
var stream = new Stream(data);
|
||||
this.pdfDocument = new PDFDocument(this, stream, password);
|
||||
this._loadedStreamCapability = createPromiseCapability();
|
||||
@ -157,9 +158,10 @@ var LocalPdfManager = (function LocalPdfManagerClosure() {
|
||||
})();
|
||||
|
||||
var NetworkPdfManager = (function NetworkPdfManagerClosure() {
|
||||
function NetworkPdfManager(docId, pdfNetworkStream, args) {
|
||||
function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions) {
|
||||
this._docId = docId;
|
||||
this.msgHandler = args.msgHandler;
|
||||
this.evaluatorOptions = evaluatorOptions;
|
||||
|
||||
var params = {
|
||||
msgHandler: args.msgHandler,
|
||||
|
@ -12,7 +12,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
@ -36,6 +35,7 @@ var Util = sharedUtil.Util;
|
||||
var error = sharedUtil.error;
|
||||
var info = sharedUtil.info;
|
||||
var isArray = sharedUtil.isArray;
|
||||
var createObjectURL = sharedUtil.createObjectURL;
|
||||
var shadow = sharedUtil.shadow;
|
||||
var warn = sharedUtil.warn;
|
||||
var Dict = corePrimitives.Dict;
|
||||
@ -959,8 +959,8 @@ var JpegStream = (function JpegStreamClosure() {
|
||||
return this.buffer;
|
||||
};
|
||||
|
||||
JpegStream.prototype.getIR = function JpegStream_getIR() {
|
||||
return PDFJS.createObjectURL(this.bytes, 'image/jpeg');
|
||||
JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
|
||||
return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
|
||||
};
|
||||
/**
|
||||
* Checks if the image can be decoded and displayed by the browser without any
|
||||
|
@ -19,18 +19,16 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/core/worker', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/core/primitives', 'pdfjs/core/pdf_manager', 'pdfjs/shared/global'],
|
||||
'pdfjs/core/primitives', 'pdfjs/core/pdf_manager'],
|
||||
factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'), require('./primitives.js'),
|
||||
require('./pdf_manager.js'), require('../shared/global.js'));
|
||||
require('./pdf_manager.js'));
|
||||
} else {
|
||||
factory((root.pdfjsCoreWorker = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsCorePrimitives, root.pdfjsCorePdfManager,
|
||||
root.pdfjsSharedGlobal);
|
||||
root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, corePrimitives, corePdfManager,
|
||||
sharedGlobal) {
|
||||
}(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
|
||||
|
||||
var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
|
||||
var InvalidPDFException = sharedUtil.InvalidPDFException;
|
||||
@ -48,11 +46,11 @@ var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
var error = sharedUtil.error;
|
||||
var info = sharedUtil.info;
|
||||
var warn = sharedUtil.warn;
|
||||
var setVerbosityLevel = sharedUtil.setVerbosityLevel;
|
||||
var Ref = corePrimitives.Ref;
|
||||
var LocalPdfManager = corePdfManager.LocalPdfManager;
|
||||
var NetworkPdfManager = corePdfManager.NetworkPdfManager;
|
||||
var globalScope = sharedGlobal.globalScope;
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var globalScope = sharedUtil.globalScope;
|
||||
|
||||
var WorkerTask = (function WorkerTaskClosure() {
|
||||
function WorkerTask(name) {
|
||||
@ -428,7 +426,7 @@ function setPDFNetworkStreamClass(cls) {
|
||||
PDFNetworkStream = cls;
|
||||
}
|
||||
|
||||
var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
var WorkerMessageHandler = {
|
||||
setup: function wphSetup(handler, port) {
|
||||
var testMessageProcessed = false;
|
||||
handler.on('test', function wphSetupTest(data) {
|
||||
@ -464,6 +462,10 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
});
|
||||
});
|
||||
|
||||
handler.on('configure', function wphConfigure(data) {
|
||||
setVerbosityLevel(data.verbosity);
|
||||
});
|
||||
|
||||
handler.on('GetDocRequest', function wphSetupDoc(data) {
|
||||
return WorkerMessageHandler.createDocumentHandler(data, port);
|
||||
});
|
||||
@ -533,14 +535,15 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
return loadDocumentCapability.promise;
|
||||
}
|
||||
|
||||
function getPdfManager(data) {
|
||||
function getPdfManager(data, evaluatorOptions) {
|
||||
var pdfManagerCapability = createPromiseCapability();
|
||||
var pdfManager;
|
||||
|
||||
var source = data.source;
|
||||
if (source.data) {
|
||||
try {
|
||||
pdfManager = new LocalPdfManager(docId, source.data, source.password);
|
||||
pdfManager = new LocalPdfManager(docId, source.data, source.password,
|
||||
evaluatorOptions);
|
||||
pdfManagerCapability.resolve(pdfManager);
|
||||
} catch (ex) {
|
||||
pdfManagerCapability.reject(ex);
|
||||
@ -589,7 +592,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
length: fullRequest.contentLength,
|
||||
disableAutoFetch: disableAutoFetch,
|
||||
rangeChunkSize: source.rangeChunkSize
|
||||
});
|
||||
}, evaluatorOptions);
|
||||
pdfManagerCapability.resolve(pdfManager);
|
||||
cancelXHRs = null;
|
||||
}).catch(function (reason) {
|
||||
@ -605,7 +608,8 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
}
|
||||
// the data is array, instantiating directly from it
|
||||
try {
|
||||
pdfManager = new LocalPdfManager(docId, pdfFile, source.password);
|
||||
pdfManager = new LocalPdfManager(docId, pdfFile, source.password,
|
||||
evaluatorOptions);
|
||||
pdfManagerCapability.resolve(pdfManager);
|
||||
} catch (ex) {
|
||||
pdfManagerCapability.reject(ex);
|
||||
@ -685,16 +689,18 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = {
|
||||
|
||||
ensureNotTerminated();
|
||||
|
||||
PDFJS.maxImageSize = data.maxImageSize === undefined ?
|
||||
-1 : data.maxImageSize;
|
||||
PDFJS.disableFontFace = data.disableFontFace;
|
||||
PDFJS.disableCreateObjectURL = data.disableCreateObjectURL;
|
||||
PDFJS.verbosity = data.verbosity;
|
||||
PDFJS.cMapUrl = data.cMapUrl === undefined ?
|
||||
null : data.cMapUrl;
|
||||
PDFJS.cMapPacked = data.cMapPacked === true;
|
||||
var cMapOptions = {
|
||||
url: data.cMapUrl === undefined ? null : data.cMapUrl,
|
||||
packed: data.cMapPacked === true
|
||||
};
|
||||
var evaluatorOptions = {
|
||||
forceDataSchema: data.disableCreateObjectURL,
|
||||
maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
|
||||
disableFontFace: data.disableFontFace,
|
||||
cMapOptions: cMapOptions
|
||||
};
|
||||
|
||||
getPdfManager(data).then(function (newPdfManager) {
|
||||
getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
|
||||
if (terminated) {
|
||||
// We were in a process of setting up the manager, but it got
|
||||
// terminated in the middle.
|
||||
|
@ -31,8 +31,8 @@
|
||||
var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
|
||||
var AnnotationType = sharedUtil.AnnotationType;
|
||||
var Util = sharedUtil.Util;
|
||||
var addLinkAttributes = sharedUtil.addLinkAttributes;
|
||||
var getFilenameFromUrl = sharedUtil.getFilenameFromUrl;
|
||||
var addLinkAttributes = displayDOMUtils.addLinkAttributes;
|
||||
var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
|
||||
var warn = sharedUtil.warn;
|
||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||
|
||||
|
@ -20,18 +20,20 @@
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/api', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/font_loader', 'pdfjs/display/canvas',
|
||||
'pdfjs/display/metadata', 'pdfjs/shared/global', 'require'], factory);
|
||||
'pdfjs/display/metadata', 'pdfjs/display/dom_utils',
|
||||
'pdfjs/display/global', 'require'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'), require('./font_loader.js'),
|
||||
require('./canvas.js'), require('./metadata.js'),
|
||||
require('../shared/global.js'));
|
||||
require('./dom_utils.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayAPI = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas,
|
||||
root.pdfjsDisplayMetadata, root.pdfjsSharedGlobal);
|
||||
root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils,
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, displayFontLoader, displayCanvas,
|
||||
displayMetadata, sharedGlobal, amdRequire) {
|
||||
displayMetadata, displayDOMUtils, displayGlobal, amdRequire) {
|
||||
|
||||
var InvalidPDFException = sharedUtil.InvalidPDFException;
|
||||
var MessageHandler = sharedUtil.MessageHandler;
|
||||
@ -46,6 +48,7 @@ var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
var combineUrl = sharedUtil.combineUrl;
|
||||
var error = sharedUtil.error;
|
||||
var deprecated = sharedUtil.deprecated;
|
||||
var getVerbosityLevel = sharedUtil.getVerbosityLevel;
|
||||
var info = sharedUtil.info;
|
||||
var isArrayBuffer = sharedUtil.isArrayBuffer;
|
||||
var isSameOrigin = sharedUtil.isSameOrigin;
|
||||
@ -57,8 +60,8 @@ var FontLoader = displayFontLoader.FontLoader;
|
||||
var CanvasGraphics = displayCanvas.CanvasGraphics;
|
||||
var createScratchCanvas = displayCanvas.createScratchCanvas;
|
||||
var Metadata = displayMetadata.Metadata;
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var globalScope = sharedGlobal.globalScope;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
var globalScope = displayGlobal.globalScope;
|
||||
|
||||
var DEFAULT_RANGE_CHUNK_SIZE = 65536; // 2^16 = 65536
|
||||
|
||||
@ -198,17 +201,6 @@ PDFJS.disableFullscreen = (PDFJS.disableFullscreen === undefined ?
|
||||
PDFJS.useOnlyCssZoom = (PDFJS.useOnlyCssZoom === undefined ?
|
||||
false : PDFJS.useOnlyCssZoom);
|
||||
|
||||
/**
|
||||
* Controls the logging level.
|
||||
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
|
||||
* - errors
|
||||
* - warnings [default]
|
||||
* - infos
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.verbosity = (PDFJS.verbosity === undefined ?
|
||||
PDFJS.VERBOSITY_LEVELS.warnings : PDFJS.verbosity);
|
||||
|
||||
/**
|
||||
* The maximum supported canvas size in total pixels e.g. width * height.
|
||||
* The default value is 4096 * 4096. Use -1 for no limit.
|
||||
@ -454,7 +446,6 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
||||
cMapPacked: PDFJS.cMapPacked,
|
||||
disableFontFace: PDFJS.disableFontFace,
|
||||
disableCreateObjectURL: PDFJS.disableCreateObjectURL,
|
||||
verbosity: PDFJS.verbosity,
|
||||
postMessageTransfers: PDFJS.postMessageTransfers,
|
||||
}).then(function (workerId) {
|
||||
if (worker.destroyed) {
|
||||
@ -1213,38 +1204,45 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
error('No PDFJS.workerSrc specified');
|
||||
}
|
||||
|
||||
var fakeWorkerFilesLoadedCapability;
|
||||
|
||||
// Loads worker code into main thread.
|
||||
function setupFakeWorkerGlobal() {
|
||||
if (!PDFJS.fakeWorkerFilesLoadedCapability) {
|
||||
PDFJS.fakeWorkerFilesLoadedCapability = createPromiseCapability();
|
||||
var WorkerMessageHandler;
|
||||
if (!fakeWorkerFilesLoadedCapability) {
|
||||
fakeWorkerFilesLoadedCapability = createPromiseCapability();
|
||||
// In the developer build load worker_loader which in turn loads all the
|
||||
// other files and resolves the promise. In production only the
|
||||
// pdf.worker.js file is needed.
|
||||
//#if !PRODUCTION
|
||||
if (typeof amdRequire === 'function') {
|
||||
amdRequire(['pdfjs/core/network', 'pdfjs/core/worker'], function () {
|
||||
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||
amdRequire(['pdfjs/core/network', 'pdfjs/core/worker'],
|
||||
function (network, worker) {
|
||||
WorkerMessageHandler = worker.WorkerMessageHandler;
|
||||
fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
|
||||
});
|
||||
} else if (typeof require === 'function') {
|
||||
require('../core/worker.js');
|
||||
PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||
var worker = require('../core/worker.js');
|
||||
WorkerMessageHandler = worker.WorkerMessageHandler;
|
||||
fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
|
||||
} else {
|
||||
throw new Error('AMD or CommonJS must be used to load fake worker.');
|
||||
}
|
||||
//#endif
|
||||
//#if PRODUCTION && SINGLE_FILE
|
||||
// PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||
// WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
|
||||
// fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
|
||||
//#endif
|
||||
//#if PRODUCTION && !SINGLE_FILE
|
||||
// var loader = fakeWorkerFilesLoader || function (callback) {
|
||||
// Util.loadScript(getWorkerSrc(), callback);
|
||||
// Util.loadScript(getWorkerSrc(), function () {
|
||||
// callback(window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
|
||||
// });
|
||||
// };
|
||||
// loader(function () {
|
||||
// PDFJS.fakeWorkerFilesLoadedCapability.resolve();
|
||||
// });
|
||||
// loader(fakeWorkerFilesLoadedCapability.resolve);
|
||||
//#endif
|
||||
}
|
||||
return PDFJS.fakeWorkerFilesLoadedCapability.promise;
|
||||
return fakeWorkerFilesLoadedCapability.promise;
|
||||
}
|
||||
|
||||
function createCDNWrapper(url) {
|
||||
@ -1318,6 +1316,10 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
PDFJS.postMessageTransfers = false;
|
||||
}
|
||||
this._readyCapability.resolve();
|
||||
// Send global PDFJS setting, e.g. verbosity level.
|
||||
messageHandler.send('configure', {
|
||||
verbosity: getVerbosityLevel()
|
||||
});
|
||||
} else {
|
||||
this._setupFakeWorker();
|
||||
messageHandler.destroy();
|
||||
@ -1383,7 +1385,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
globalScope.PDFJS.disableWorker = true;
|
||||
}
|
||||
|
||||
setupFakeWorkerGlobal().then(function () {
|
||||
setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
|
||||
if (this.destroyed) {
|
||||
this._readyCapability.reject(new Error('Worker was destroyed'));
|
||||
return;
|
||||
@ -1415,7 +1417,7 @@ var PDFWorker = (function PDFWorkerClosure() {
|
||||
// If the main thread is our worker, setup the handling for the
|
||||
// messages -- the main thread sends to it self.
|
||||
var workerHandler = new MessageHandler(id + '_worker', id, port);
|
||||
PDFJS.WorkerMessageHandler.setup(workerHandler, port);
|
||||
WorkerMessageHandler.setup(workerHandler, port);
|
||||
|
||||
var messageHandler = new MessageHandler(id, id + '_worker', port);
|
||||
this._messageHandler = messageHandler;
|
||||
|
@ -19,15 +19,18 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/canvas', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/pattern_helper', 'pdfjs/display/webgl'], factory);
|
||||
'pdfjs/display/dom_utils', 'pdfjs/display/pattern_helper',
|
||||
'pdfjs/display/webgl'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'),
|
||||
factory(exports, require('../shared/util.js'), require('./dom_utils.js'),
|
||||
require('./pattern_helper.js'), require('./webgl.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayCanvas = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
|
||||
root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper,
|
||||
root.pdfjsDisplayWebGL);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, displayPatternHelper, displayWebGL) {
|
||||
}(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper,
|
||||
displayWebGL) {
|
||||
|
||||
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
||||
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
||||
|
@ -17,16 +17,21 @@
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/dom_utils', ['exports', 'pdfjs/shared/global'],
|
||||
factory);
|
||||
define('pdfjs/display/dom_utils', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/global.js'));
|
||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedGlobal);
|
||||
factory((root.pdfjsDisplayDOMUtils = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedGlobal) {
|
||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
||||
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var deprecated = sharedUtil.deprecated;
|
||||
var removeNullCharacters = sharedUtil.removeNullCharacters;
|
||||
var shadow = sharedUtil.shadow;
|
||||
var warn = sharedUtil.warn;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
/**
|
||||
* Optimised CSS custom property getter/setter.
|
||||
@ -84,5 +89,106 @@ var CustomStyle = (function CustomStyleClosure() {
|
||||
|
||||
PDFJS.CustomStyle = CustomStyle;
|
||||
|
||||
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||
//// Lazy test if the userAgent support CanvasTypedArrays
|
||||
function hasCanvasTypedArrays() {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = 1;
|
||||
var ctx = canvas.getContext('2d');
|
||||
var imageData = ctx.createImageData(1, 1);
|
||||
return (typeof imageData.data.buffer !== 'undefined');
|
||||
}
|
||||
|
||||
Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
|
||||
configurable: true,
|
||||
get: function PDFJS_hasCanvasTypedArrays() {
|
||||
return shadow(PDFJS, 'hasCanvasTypedArrays', hasCanvasTypedArrays());
|
||||
}
|
||||
});
|
||||
//#else
|
||||
//PDFJS.hasCanvasTypedArrays = true;
|
||||
//#endif
|
||||
|
||||
var LinkTarget = {
|
||||
NONE: 0, // Default value.
|
||||
SELF: 1,
|
||||
BLANK: 2,
|
||||
PARENT: 3,
|
||||
TOP: 4,
|
||||
};
|
||||
|
||||
PDFJS.LinkTarget = LinkTarget;
|
||||
|
||||
var LinkTargetStringMap = [
|
||||
'',
|
||||
'_self',
|
||||
'_blank',
|
||||
'_parent',
|
||||
'_top'
|
||||
];
|
||||
|
||||
function isExternalLinkTargetSet() {
|
||||
//#if !MOZCENTRAL
|
||||
if (PDFJS.openExternalLinksInNewWindow) {
|
||||
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
|
||||
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
|
||||
if (PDFJS.externalLinkTarget === LinkTarget.NONE) {
|
||||
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.
|
||||
* @param {HTMLLinkElement} link - The link element.
|
||||
* @param {Object} params - An object with the properties:
|
||||
* @param {string} params.url - An absolute URL.
|
||||
*/
|
||||
function addLinkAttributes(link, params) {
|
||||
var url = params && params.url;
|
||||
link.href = link.title = (url ? removeNullCharacters(url) : '');
|
||||
|
||||
if (url) {
|
||||
if (isExternalLinkTargetSet()) {
|
||||
link.target = LinkTargetStringMap[PDFJS.externalLinkTarget];
|
||||
}
|
||||
// Strip referrer from the URL.
|
||||
link.rel = PDFJS.externalLinkRel;
|
||||
}
|
||||
}
|
||||
PDFJS.addLinkAttributes = addLinkAttributes;
|
||||
|
||||
// Gets the file name from a given URL.
|
||||
function getFilenameFromUrl(url) {
|
||||
var anchor = url.indexOf('#');
|
||||
var query = url.indexOf('?');
|
||||
var end = Math.min(
|
||||
anchor > 0 ? anchor : url.length,
|
||||
query > 0 ? query : url.length);
|
||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||
}
|
||||
PDFJS.getFilenameFromUrl = getFilenameFromUrl;
|
||||
|
||||
exports.CustomStyle = CustomStyle;
|
||||
exports.addLinkAttributes = addLinkAttributes;
|
||||
exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
|
||||
exports.getFilenameFromUrl = getFilenameFromUrl;
|
||||
exports.LinkTarget = LinkTarget;
|
||||
}));
|
||||
|
@ -19,15 +19,14 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/font_loader', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/shared/global'], factory);
|
||||
'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'),
|
||||
require('../shared/global.js'));
|
||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayFontLoader = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsSharedGlobal);
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, sharedGlobal) {
|
||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
||||
|
||||
var assert = sharedUtil.assert;
|
||||
var bytesToString = sharedUtil.bytesToString;
|
||||
@ -35,9 +34,9 @@ var string32 = sharedUtil.string32;
|
||||
var shadow = sharedUtil.shadow;
|
||||
var warn = sharedUtil.warn;
|
||||
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var globalScope = sharedGlobal.globalScope;
|
||||
var isWorker = sharedGlobal.isWorker;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
var globalScope = displayGlobal.globalScope;
|
||||
var isWorker = displayGlobal.isWorker;
|
||||
|
||||
function FontLoader(docId) {
|
||||
this.docId = docId;
|
||||
|
92
src/display/global.js
Normal file
92
src/display/global.js
Normal file
@ -0,0 +1,92 @@
|
||||
/* Copyright 2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals pdfjsVersion, pdfjsBuild */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/global', ['exports', 'pdfjs/shared/util'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayGlobal = {}), root.pdfjsSharedUtil);
|
||||
}
|
||||
}(this, function (exports, sharedUtil) {
|
||||
|
||||
var globalScope = sharedUtil.globalScope;
|
||||
|
||||
var isWorker = (typeof window === 'undefined');
|
||||
|
||||
// The global PDFJS object exposes the API
|
||||
// In production, it will be declared outside a global wrapper
|
||||
// In development, it will be declared here
|
||||
if (!globalScope.PDFJS) {
|
||||
globalScope.PDFJS = {};
|
||||
}
|
||||
var PDFJS = globalScope.PDFJS;
|
||||
|
||||
if (typeof pdfjsVersion !== 'undefined') {
|
||||
PDFJS.version = pdfjsVersion;
|
||||
}
|
||||
if (typeof pdfjsBuild !== 'undefined') {
|
||||
PDFJS.build = pdfjsBuild;
|
||||
}
|
||||
|
||||
PDFJS.pdfBug = false;
|
||||
|
||||
if (PDFJS.verbosity !== undefined) {
|
||||
sharedUtil.setVerbosityLevel(PDFJS.verbosity);
|
||||
}
|
||||
delete PDFJS.verbosity;
|
||||
Object.defineProperty(PDFJS, 'verbosity', {
|
||||
get: function () { return sharedUtil.getVerbosityLevel(); },
|
||||
set: function (level) { sharedUtil.setVerbosityLevel(level); },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
|
||||
PDFJS.OPS = sharedUtil.OPS;
|
||||
PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
|
||||
PDFJS.isValidUrl = sharedUtil.isValidUrl;
|
||||
PDFJS.shadow = sharedUtil.shadow;
|
||||
PDFJS.createBlob = sharedUtil.createBlob;
|
||||
PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
|
||||
return sharedUtil.createObjectURL(data, contentType,
|
||||
PDFJS.disableCreateObjectURL);
|
||||
};
|
||||
Object.defineProperty(PDFJS, 'isLittleEndian', {
|
||||
configurable: true,
|
||||
get: function PDFJS_isLittleEndian() {
|
||||
var value = sharedUtil.isLittleEndian();
|
||||
return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
|
||||
}
|
||||
});
|
||||
PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
|
||||
PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
|
||||
PDFJS.PasswordException = sharedUtil.PasswordException;
|
||||
PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
|
||||
PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
|
||||
PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
|
||||
PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
|
||||
PDFJS.Util = sharedUtil.Util;
|
||||
PDFJS.PageViewport = sharedUtil.PageViewport;
|
||||
PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
|
||||
exports.globalScope = globalScope;
|
||||
exports.isWorker = isWorker;
|
||||
exports.PDFJS = globalScope.PDFJS;
|
||||
}));
|
@ -12,21 +12,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS, Document */
|
||||
/* globals Document */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/metadata', ['exports', 'pdfjs/shared/util'], factory);
|
||||
define('pdfjs/display/metadata', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'));
|
||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil);
|
||||
factory((root.pdfjsDisplayMetadata = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil) {
|
||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
||||
|
||||
var error = sharedUtil.error;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
var Metadata = PDFJS.Metadata = (function MetadataClosure() {
|
||||
function fixMetadata(meta) {
|
||||
|
@ -12,20 +12,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
|
||||
'use strict';
|
||||
|
||||
//#if (GENERIC || SINGLE_FILE)
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util'], factory);
|
||||
define('pdfjs/display/svg', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'));
|
||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil);
|
||||
factory((root.pdfjsDisplaySVG = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil) {
|
||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
||||
|
||||
var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
|
||||
var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
|
||||
@ -35,6 +36,7 @@ var Util = sharedUtil.Util;
|
||||
var isNum = sharedUtil.isNum;
|
||||
var isArray = sharedUtil.isArray;
|
||||
var warn = sharedUtil.warn;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
var SVG_DEFAULTS = {
|
||||
fontStyle: 'normal',
|
||||
|
@ -18,20 +18,20 @@
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/text_layer', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/dom_utils', 'pdfjs/shared/global'], factory);
|
||||
'pdfjs/display/dom_utils', 'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'), require('./dom_utils.js'),
|
||||
require('../shared/global.js'));
|
||||
require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayTextLayer = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayDOMUtils, root.pdfjsSharedGlobal);
|
||||
root.pdfjsDisplayDOMUtils, root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil, displayDOMUtils, sharedGlobal) {
|
||||
}(this, function (exports, sharedUtil, displayDOMUtils, displayGlobal) {
|
||||
|
||||
var Util = sharedUtil.Util;
|
||||
var createPromiseCapability = sharedUtil.createPromiseCapability;
|
||||
var CustomStyle = displayDOMUtils.CustomStyle;
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
/**
|
||||
* Text layer render parameters.
|
||||
|
@ -12,22 +12,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals PDFJS */
|
||||
/* jshint -W043 */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/display/webgl', ['exports', 'pdfjs/shared/util'], factory);
|
||||
define('pdfjs/display/webgl', ['exports', 'pdfjs/shared/util',
|
||||
'pdfjs/display/global'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('../shared/util.js'));
|
||||
factory(exports, require('../shared/util.js'), require('./global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil);
|
||||
factory((root.pdfjsDisplayWebGL = {}), root.pdfjsSharedUtil,
|
||||
root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, sharedUtil) {
|
||||
}(this, function (exports, sharedUtil, displayGlobal) {
|
||||
|
||||
var shadow = sharedUtil.shadow;
|
||||
var PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
var WebGLUtils = (function WebGLUtilsClosure() {
|
||||
function loadShader(gl, code, shaderType) {
|
||||
|
@ -27,6 +27,16 @@ function PDFJS() {
|
||||
// Mock class constructor. See src/display/api.js.
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls the logging level.
|
||||
* The constants from PDFJS.VERBOSITY_LEVELS should be used:
|
||||
* - errors
|
||||
* - warnings [default]
|
||||
* - infos
|
||||
* @var {number}
|
||||
*/
|
||||
PDFJS.verbosity = PDFJS.VERBOSITY_LEVELS.warnings;
|
||||
|
||||
/**
|
||||
* Represents the eventual result of an asynchronous operation.
|
||||
* @external Promise
|
||||
|
@ -37,11 +37,11 @@ if (typeof requirejs !== 'undefined' && requirejs.toUrl) {
|
||||
}
|
||||
var fakeWorkerFilesLoader = useRequireEnsure ? (function (callback) {
|
||||
require.ensure([], function () {
|
||||
require('./pdf.worker.js');
|
||||
callback();
|
||||
var worker = require('./pdf.worker.js');
|
||||
callback(worker.WorkerMessageHandler);
|
||||
});
|
||||
}) : (typeof requirejs !== 'undefined') ? (function (callback) {
|
||||
requirejs(['pdfjs-dist/build/pdf.worker'], function (worker) {
|
||||
callback();
|
||||
callback(worker.WorkerMessageHandler);
|
||||
});
|
||||
}) : null;
|
||||
|
@ -19,23 +19,24 @@
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/main_loader', ['exports', 'pdfjs/display/api',
|
||||
'pdfjs/display/annotation_layer', 'pdfjs/display/text_layer',
|
||||
'pdfjs/display/dom_utils', 'pdfjs/shared/util', 'pdfjs/shared/global'],
|
||||
'pdfjs/display/dom_utils', 'pdfjs/shared/util', 'pdfjs/display/global'],
|
||||
factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('./display/api.js'),
|
||||
require('./display/annotation_layer.js'),
|
||||
require('./display/text_layer.js'), require('./display/dom_utils.js'),
|
||||
require('./shared/util.js'), require('./shared/global.js'));
|
||||
require('./shared/util.js'), require('./display/global.js'));
|
||||
} else {
|
||||
factory((root.pdfjsMainLoader = {}), root.pdfjsDisplayAPI,
|
||||
root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer,
|
||||
root.pdfjsDisplayDOMUtils, root.pdfjsSharedUtil, root.pdfjsSharedGlobal);
|
||||
root.pdfjsDisplayDOMUtils, root.pdfjsSharedUtil, root.pdfjsDisplayGlobal);
|
||||
}
|
||||
}(this, function (exports, displayAPI, displayAnnotationLayer,
|
||||
displayTextLayer, displayDOMUtils, sharedUtil, sharedGlobal) {
|
||||
displayTextLayer, displayDOMUtils, sharedUtil,
|
||||
displayGlobal) {
|
||||
|
||||
// Sync the exports below with ./pdf.js file/template.
|
||||
exports.PDFJS = sharedGlobal.PDFJS;
|
||||
exports.PDFJS = displayGlobal.PDFJS;
|
||||
|
||||
exports.getDocument = displayAPI.getDocument;
|
||||
exports.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
|
||||
|
@ -43,9 +43,8 @@
|
||||
|
||||
}).call(pdfjsLibs);
|
||||
|
||||
exports.PDFJS = pdfjsLibs.pdfjsSharedGlobal.PDFJS;
|
||||
|
||||
//#if MAIN_FILE
|
||||
exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
|
||||
exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
|
||||
exports.PDFDataRangeTransport =
|
||||
pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
|
||||
@ -58,5 +57,7 @@
|
||||
exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
|
||||
exports.UnexpectedResponseException =
|
||||
pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
|
||||
//#else
|
||||
exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
|
||||
//#endif
|
||||
}));
|
||||
|
@ -1,54 +0,0 @@
|
||||
/* Copyright 2015 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals global, pdfjsVersion, pdfjsBuild */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/shared/global', ['exports'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports);
|
||||
} else {
|
||||
factory((root.pdfjsSharedGlobal = {}));
|
||||
}
|
||||
}(this, function (exports) {
|
||||
|
||||
var globalScope = (typeof window !== 'undefined') ? window :
|
||||
(typeof global !== 'undefined') ? global :
|
||||
(typeof self !== 'undefined') ? self : this;
|
||||
|
||||
var isWorker = (typeof window === 'undefined');
|
||||
|
||||
// The global PDFJS object exposes the API
|
||||
// In production, it will be declared outside a global wrapper
|
||||
// In development, it will be declared here
|
||||
if (!globalScope.PDFJS) {
|
||||
globalScope.PDFJS = {};
|
||||
}
|
||||
|
||||
if (typeof pdfjsVersion !== 'undefined') {
|
||||
globalScope.PDFJS.version = pdfjsVersion;
|
||||
}
|
||||
if (typeof pdfjsVersion !== 'undefined') {
|
||||
globalScope.PDFJS.build = pdfjsBuild;
|
||||
}
|
||||
|
||||
globalScope.PDFJS.pdfBug = false;
|
||||
|
||||
exports.globalScope = globalScope;
|
||||
exports.isWorker = isWorker;
|
||||
exports.PDFJS = globalScope.PDFJS;
|
||||
}));
|
@ -12,22 +12,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
/* globals MozBlobBuilder, URL */
|
||||
/* globals MozBlobBuilder, URL, global */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define('pdfjs/shared/util', ['exports', 'pdfjs/shared/global'], factory);
|
||||
define('pdfjs/shared/util', ['exports'], factory);
|
||||
} else if (typeof exports !== 'undefined') {
|
||||
factory(exports, require('./global.js'));
|
||||
factory(exports);
|
||||
} else {
|
||||
factory((root.pdfjsSharedUtil = {}), root.pdfjsSharedGlobal);
|
||||
factory((root.pdfjsSharedUtil = {}));
|
||||
}
|
||||
}(this, function (exports, sharedGlobal) {
|
||||
}(this, function (exports) {
|
||||
|
||||
var PDFJS = sharedGlobal.PDFJS;
|
||||
var globalScope = sharedGlobal.globalScope;
|
||||
var globalScope = (typeof window !== 'undefined') ? window :
|
||||
(typeof global !== 'undefined') ? global :
|
||||
(typeof self !== 'undefined') ? self : this;
|
||||
|
||||
var FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
|
||||
|
||||
@ -127,14 +128,14 @@ var FontType = {
|
||||
MMTYPE1: 10
|
||||
};
|
||||
|
||||
PDFJS.VERBOSITY_LEVELS = {
|
||||
var VERBOSITY_LEVELS = {
|
||||
errors: 0,
|
||||
warnings: 1,
|
||||
infos: 5
|
||||
};
|
||||
|
||||
// All the possible operations for an operator list.
|
||||
var OPS = PDFJS.OPS = {
|
||||
var OPS = {
|
||||
// Intentionally start from 1 so it is easy to spot bad operators that will be
|
||||
// 0's.
|
||||
dependency: 1,
|
||||
@ -230,18 +231,28 @@ var OPS = PDFJS.OPS = {
|
||||
constructPath: 91
|
||||
};
|
||||
|
||||
var verbosity = VERBOSITY_LEVELS.warnings;
|
||||
|
||||
function setVerbosityLevel(level) {
|
||||
verbosity = level;
|
||||
}
|
||||
|
||||
function getVerbosityLevel() {
|
||||
return verbosity;
|
||||
}
|
||||
|
||||
// A notice for devs. These are good for things that are helpful to devs, such
|
||||
// as warning that Workers were disabled, which is important to devs but not
|
||||
// end users.
|
||||
function info(msg) {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.infos) {
|
||||
if (verbosity >= VERBOSITY_LEVELS.infos) {
|
||||
console.log('Info: ' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
// Non-fatal warnings.
|
||||
function warn(msg) {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.warnings) {
|
||||
if (verbosity >= VERBOSITY_LEVELS.warnings) {
|
||||
console.log('Warning: ' + msg);
|
||||
}
|
||||
}
|
||||
@ -254,7 +265,7 @@ function deprecated(details) {
|
||||
// Fatal errors that should trigger the fallback UI and halt execution by
|
||||
// throwing an exception.
|
||||
function error(msg) {
|
||||
if (PDFJS.verbosity >= PDFJS.VERBOSITY_LEVELS.errors) {
|
||||
if (verbosity >= VERBOSITY_LEVELS.errors) {
|
||||
console.log('Error: ' + msg);
|
||||
console.log(backtrace());
|
||||
}
|
||||
@ -275,7 +286,7 @@ function assert(cond, msg) {
|
||||
}
|
||||
}
|
||||
|
||||
var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
||||
var UNSUPPORTED_FEATURES = {
|
||||
unknown: 'unknown',
|
||||
forms: 'forms',
|
||||
javaScript: 'javaScript',
|
||||
@ -284,17 +295,6 @@ var UNSUPPORTED_FEATURES = PDFJS.UNSUPPORTED_FEATURES = {
|
||||
font: 'font'
|
||||
};
|
||||
|
||||
// Gets the file name from a given URL.
|
||||
function getFilenameFromUrl(url) {
|
||||
var anchor = url.indexOf('#');
|
||||
var query = url.indexOf('?');
|
||||
var end = Math.min(
|
||||
anchor > 0 ? anchor : url.length,
|
||||
query > 0 ? query : url.length);
|
||||
return url.substring(url.lastIndexOf('/', end) + 1, end);
|
||||
}
|
||||
PDFJS.getFilenameFromUrl = getFilenameFromUrl;
|
||||
|
||||
// Combines two URLs. The baseUrl shall be absolute URL. If the url is an
|
||||
// absolute URL, it will be returned as is.
|
||||
function combineUrl(baseUrl, url) {
|
||||
@ -342,27 +342,6 @@ function isValidUrl(url, allowRelative) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PDFJS.isValidUrl = isValidUrl;
|
||||
|
||||
/**
|
||||
* Adds various attributes (href, title, target, rel) to hyperlinks.
|
||||
* @param {HTMLLinkElement} link - The link element.
|
||||
* @param {Object} params - An object with the properties:
|
||||
* @param {string} params.url - An absolute URL.
|
||||
*/
|
||||
function addLinkAttributes(link, params) {
|
||||
var url = params && params.url;
|
||||
link.href = link.title = (url ? removeNullCharacters(url) : '');
|
||||
|
||||
if (url) {
|
||||
if (isExternalLinkTargetSet()) {
|
||||
link.target = LinkTargetStringMap[PDFJS.externalLinkTarget];
|
||||
}
|
||||
// Strip referrer from the URL.
|
||||
link.rel = PDFJS.externalLinkRel;
|
||||
}
|
||||
}
|
||||
PDFJS.addLinkAttributes = addLinkAttributes;
|
||||
|
||||
function shadow(obj, prop, value) {
|
||||
Object.defineProperty(obj, prop, { value: value,
|
||||
@ -371,7 +350,6 @@ function shadow(obj, prop, value) {
|
||||
writable: false });
|
||||
return value;
|
||||
}
|
||||
PDFJS.shadow = shadow;
|
||||
|
||||
function getLookupTableFactory(initializer) {
|
||||
var lookup;
|
||||
@ -385,50 +363,7 @@ function getLookupTableFactory(initializer) {
|
||||
};
|
||||
}
|
||||
|
||||
var LinkTarget = PDFJS.LinkTarget = {
|
||||
NONE: 0, // Default value.
|
||||
SELF: 1,
|
||||
BLANK: 2,
|
||||
PARENT: 3,
|
||||
TOP: 4,
|
||||
};
|
||||
var LinkTargetStringMap = [
|
||||
'',
|
||||
'_self',
|
||||
'_blank',
|
||||
'_parent',
|
||||
'_top'
|
||||
];
|
||||
|
||||
function isExternalLinkTargetSet() {
|
||||
//#if !MOZCENTRAL
|
||||
if (PDFJS.openExternalLinksInNewWindow) {
|
||||
deprecated('PDFJS.openExternalLinksInNewWindow, please use ' +
|
||||
'"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
|
||||
if (PDFJS.externalLinkTarget === LinkTarget.NONE) {
|
||||
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;
|
||||
|
||||
var PasswordResponses = PDFJS.PasswordResponses = {
|
||||
var PasswordResponses = {
|
||||
NEED_PASSWORD: 1,
|
||||
INCORRECT_PASSWORD: 2
|
||||
};
|
||||
@ -445,7 +380,6 @@ var PasswordException = (function PasswordExceptionClosure() {
|
||||
|
||||
return PasswordException;
|
||||
})();
|
||||
PDFJS.PasswordException = PasswordException;
|
||||
|
||||
var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
||||
function UnknownErrorException(msg, details) {
|
||||
@ -459,7 +393,6 @@ var UnknownErrorException = (function UnknownErrorExceptionClosure() {
|
||||
|
||||
return UnknownErrorException;
|
||||
})();
|
||||
PDFJS.UnknownErrorException = UnknownErrorException;
|
||||
|
||||
var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
||||
function InvalidPDFException(msg) {
|
||||
@ -472,7 +405,6 @@ var InvalidPDFException = (function InvalidPDFExceptionClosure() {
|
||||
|
||||
return InvalidPDFException;
|
||||
})();
|
||||
PDFJS.InvalidPDFException = InvalidPDFException;
|
||||
|
||||
var MissingPDFException = (function MissingPDFExceptionClosure() {
|
||||
function MissingPDFException(msg) {
|
||||
@ -485,7 +417,6 @@ var MissingPDFException = (function MissingPDFExceptionClosure() {
|
||||
|
||||
return MissingPDFException;
|
||||
})();
|
||||
PDFJS.MissingPDFException = MissingPDFException;
|
||||
|
||||
var UnexpectedResponseException =
|
||||
(function UnexpectedResponseExceptionClosure() {
|
||||
@ -500,7 +431,6 @@ var UnexpectedResponseException =
|
||||
|
||||
return UnexpectedResponseException;
|
||||
})();
|
||||
PDFJS.UnexpectedResponseException = UnexpectedResponseException;
|
||||
|
||||
var NotImplementedException = (function NotImplementedExceptionClosure() {
|
||||
function NotImplementedException(msg) {
|
||||
@ -549,7 +479,6 @@ function removeNullCharacters(str) {
|
||||
}
|
||||
return str.replace(NullCharactersRegExp, '');
|
||||
}
|
||||
PDFJS.removeNullCharacters = removeNullCharacters;
|
||||
|
||||
function bytesToString(bytes) {
|
||||
assert(bytes !== null && typeof bytes === 'object' &&
|
||||
@ -663,30 +592,7 @@ function isLittleEndian() {
|
||||
return (buffer16[0] === 1);
|
||||
}
|
||||
|
||||
Object.defineProperty(PDFJS, 'isLittleEndian', {
|
||||
configurable: true,
|
||||
get: function PDFJS_isLittleEndian() {
|
||||
return shadow(PDFJS, 'isLittleEndian', isLittleEndian());
|
||||
}
|
||||
});
|
||||
|
||||
//#if !(FIREFOX || MOZCENTRAL || CHROME)
|
||||
//// Lazy test if the userAgent support CanvasTypedArrays
|
||||
function hasCanvasTypedArrays() {
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = canvas.height = 1;
|
||||
var ctx = canvas.getContext('2d');
|
||||
var imageData = ctx.createImageData(1, 1);
|
||||
return (typeof imageData.data.buffer !== 'undefined');
|
||||
}
|
||||
|
||||
Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
|
||||
configurable: true,
|
||||
get: function PDFJS_hasCanvasTypedArrays() {
|
||||
return shadow(PDFJS, 'hasCanvasTypedArrays', hasCanvasTypedArrays());
|
||||
}
|
||||
});
|
||||
|
||||
var Uint32ArrayView = (function Uint32ArrayViewClosure() {
|
||||
|
||||
function Uint32ArrayView(buffer, length) {
|
||||
@ -728,13 +634,11 @@ var Uint32ArrayView = (function Uint32ArrayViewClosure() {
|
||||
})();
|
||||
|
||||
exports.Uint32ArrayView = Uint32ArrayView;
|
||||
//#else
|
||||
//PDFJS.hasCanvasTypedArrays = true;
|
||||
//#endif
|
||||
|
||||
var IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
|
||||
|
||||
var Util = PDFJS.Util = (function UtilClosure() {
|
||||
var Util = (function UtilClosure() {
|
||||
function Util() {}
|
||||
|
||||
var rgbBuf = ['rgb(', 0, ',', 0, ',', 0, ')'];
|
||||
@ -987,7 +891,7 @@ var Util = PDFJS.Util = (function UtilClosure() {
|
||||
* @class
|
||||
* @alias PDFJS.PageViewport
|
||||
*/
|
||||
var PageViewport = PDFJS.PageViewport = (function PageViewportClosure() {
|
||||
var PageViewport = (function PageViewportClosure() {
|
||||
/**
|
||||
* @constructor
|
||||
* @private
|
||||
@ -1211,8 +1115,6 @@ function createPromiseCapability() {
|
||||
return capability;
|
||||
}
|
||||
|
||||
PDFJS.createPromiseCapability = createPromiseCapability;
|
||||
|
||||
/**
|
||||
* Polyfill for Promises:
|
||||
* The following promise implementation tries to generally implement the
|
||||
@ -1593,7 +1495,7 @@ var StatTimer = (function StatTimerClosure() {
|
||||
return StatTimer;
|
||||
})();
|
||||
|
||||
PDFJS.createBlob = function createBlob(data, contentType) {
|
||||
var createBlob = function createBlob(data, contentType) {
|
||||
if (typeof Blob !== 'undefined') {
|
||||
return new Blob([data], { type: contentType });
|
||||
}
|
||||
@ -1603,15 +1505,15 @@ PDFJS.createBlob = function createBlob(data, contentType) {
|
||||
return bb.getBlob(contentType);
|
||||
};
|
||||
|
||||
PDFJS.createObjectURL = (function createObjectURLClosure() {
|
||||
var createObjectURL = (function createObjectURLClosure() {
|
||||
// Blob/createObjectURL is not available, falling back to data schema.
|
||||
var digits =
|
||||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
return function createObjectURL(data, contentType) {
|
||||
if (!PDFJS.disableCreateObjectURL &&
|
||||
return function createObjectURL(data, contentType, forceDataSchema) {
|
||||
if (!forceDataSchema &&
|
||||
typeof URL !== 'undefined' && URL.createObjectURL) {
|
||||
var blob = PDFJS.createBlob(data, contentType);
|
||||
var blob = createBlob(data, contentType);
|
||||
return URL.createObjectURL(blob);
|
||||
}
|
||||
|
||||
@ -2399,6 +2301,7 @@ function loadJpegStream(id, imageUrl, objs) {
|
||||
exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
|
||||
exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
|
||||
exports.OPS = OPS;
|
||||
exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
|
||||
exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
|
||||
exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
|
||||
exports.AnnotationFlag = AnnotationFlag;
|
||||
@ -2406,12 +2309,11 @@ exports.AnnotationType = AnnotationType;
|
||||
exports.FontType = FontType;
|
||||
exports.ImageKind = ImageKind;
|
||||
exports.InvalidPDFException = InvalidPDFException;
|
||||
exports.LinkTarget = LinkTarget;
|
||||
exports.LinkTargetStringMap = LinkTargetStringMap;
|
||||
exports.MessageHandler = MessageHandler;
|
||||
exports.MissingDataException = MissingDataException;
|
||||
exports.MissingPDFException = MissingPDFException;
|
||||
exports.NotImplementedException = NotImplementedException;
|
||||
exports.PageViewport = PageViewport;
|
||||
exports.PasswordException = PasswordException;
|
||||
exports.PasswordResponses = PasswordResponses;
|
||||
exports.StatTimer = StatTimer;
|
||||
@ -2426,29 +2328,32 @@ exports.arraysToBytes = arraysToBytes;
|
||||
exports.assert = assert;
|
||||
exports.bytesToString = bytesToString;
|
||||
exports.combineUrl = combineUrl;
|
||||
exports.createBlob = createBlob;
|
||||
exports.createPromiseCapability = createPromiseCapability;
|
||||
exports.createObjectURL = createObjectURL;
|
||||
exports.deprecated = deprecated;
|
||||
exports.error = error;
|
||||
exports.getFilenameFromUrl = getFilenameFromUrl;
|
||||
exports.getLookupTableFactory = getLookupTableFactory;
|
||||
exports.getVerbosityLevel = getVerbosityLevel;
|
||||
exports.globalScope = globalScope;
|
||||
exports.info = info;
|
||||
exports.isArray = isArray;
|
||||
exports.isArrayBuffer = isArrayBuffer;
|
||||
exports.isBool = isBool;
|
||||
exports.isEmptyObj = isEmptyObj;
|
||||
exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
|
||||
exports.isInt = isInt;
|
||||
exports.isNum = isNum;
|
||||
exports.isString = isString;
|
||||
exports.isSameOrigin = isSameOrigin;
|
||||
exports.isValidUrl = isValidUrl;
|
||||
exports.addLinkAttributes = addLinkAttributes;
|
||||
exports.isLittleEndian = isLittleEndian;
|
||||
exports.loadJpegStream = loadJpegStream;
|
||||
exports.log2 = log2;
|
||||
exports.readInt8 = readInt8;
|
||||
exports.readUint16 = readUint16;
|
||||
exports.readUint32 = readUint32;
|
||||
exports.removeNullCharacters = removeNullCharacters;
|
||||
exports.setVerbosityLevel = setVerbosityLevel;
|
||||
exports.shadow = shadow;
|
||||
exports.string32 = string32;
|
||||
exports.stringToBytes = stringToBytes;
|
||||
|
50
test/unit/dom_utils_spec.js
Normal file
50
test/unit/dom_utils_spec.js
Normal file
@ -0,0 +1,50 @@
|
||||
/* globals expect, it, describe, PDFJS, isExternalLinkTargetSet, LinkTarget,
|
||||
getFilenameFromUrl */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('dom_utils', function() {
|
||||
describe('getFilenameFromUrl', function() {
|
||||
it('should get the filename from an absolute URL', function() {
|
||||
var url = 'http://server.org/filename.pdf';
|
||||
var result = getFilenameFromUrl(url);
|
||||
var expected = 'filename.pdf';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should get the filename from a relative URL', function() {
|
||||
var url = '../../filename.pdf';
|
||||
var result = getFilenameFromUrl(url);
|
||||
var expected = 'filename.pdf';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isExternalLinkTargetSet', function() {
|
||||
// Save the current state, to avoid interfering with other tests.
|
||||
var previousExternalLinkTarget = PDFJS.externalLinkTarget;
|
||||
|
||||
it('handles the predefined LinkTargets', function() {
|
||||
for (var key in LinkTarget) {
|
||||
var linkTarget = LinkTarget[key];
|
||||
PDFJS.externalLinkTarget = linkTarget;
|
||||
|
||||
expect(isExternalLinkTargetSet()).toEqual(!!linkTarget);
|
||||
}
|
||||
});
|
||||
|
||||
it('handles incorrect LinkTargets', function() {
|
||||
var targets = [true, '', false, -1, '_blank', null];
|
||||
|
||||
for (var i = 0, ii = targets.length; i < ii; i++) {
|
||||
var linkTarget = targets[i];
|
||||
PDFJS.externalLinkTarget = linkTarget;
|
||||
|
||||
expect(isExternalLinkTargetSet()).toEqual(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Reset the state.
|
||||
PDFJS.externalLinkTarget = previousExternalLinkTarget;
|
||||
});
|
||||
});
|
@ -37,6 +37,7 @@
|
||||
<script src="cmap_spec.js"></script>
|
||||
<script src="annotation_layer_spec.js"></script>
|
||||
<script src="network_spec.js"></script>
|
||||
<script src="dom_utils_spec.js"></script>
|
||||
|
||||
<script>
|
||||
'use strict';
|
||||
@ -45,20 +46,20 @@
|
||||
|
||||
function initializePDFJS(callback) {
|
||||
require.config({paths: {'pdfjs': '../../src'}});
|
||||
require(['pdfjs/shared/util', 'pdfjs/shared/global', 'pdfjs/core/primitives',
|
||||
require(['pdfjs/shared/util', 'pdfjs/display/global', 'pdfjs/core/primitives',
|
||||
'pdfjs/core/annotation', 'pdfjs/core/crypto', 'pdfjs/core/stream',
|
||||
'pdfjs/core/fonts', 'pdfjs/core/ps_parser', 'pdfjs/core/function',
|
||||
'pdfjs/core/parser', 'pdfjs/core/evaluator', 'pdfjs/core/cmap',
|
||||
'pdfjs/core/worker', 'pdfjs/core/network', 'pdfjs/display/api',
|
||||
'pdfjs/display/metadata'],
|
||||
function (sharedUtil, sharedGlobal, corePrimitives, coreAnnotation,
|
||||
'pdfjs/display/metadata', 'pdfjs/display/dom_utils'],
|
||||
function (sharedUtil, displayGlobal, corePrimitives, coreAnnotation,
|
||||
coreCrypto, coreStream, coreFonts, corePsParser, coreFunction,
|
||||
coreParser, coreEvaluator, coreCMap, coreWorker,
|
||||
coreNetwork, displayAPI, displayMetadata) {
|
||||
coreParser, coreEvaluator, coreCMap, coreWorker, coreNetwork,
|
||||
displayAPI, displayMetadata, displayDOMUtils) {
|
||||
|
||||
pdfjsLibs = {
|
||||
sharedUtil: sharedUtil,
|
||||
sharedGlobal: sharedGlobal,
|
||||
displayGlobal: displayGlobal,
|
||||
corePrimitives: corePrimitives,
|
||||
coreAnnotation: coreAnnotation,
|
||||
coreCrypto: coreCrypto,
|
||||
@ -72,7 +73,8 @@
|
||||
coreWorker: coreWorker,
|
||||
coreNetwork: coreNetwork,
|
||||
displayAPI: displayAPI,
|
||||
displayMetadata: displayMetadata
|
||||
displayMetadata: displayMetadata,
|
||||
displayDOMUtils: displayDOMUtils
|
||||
};
|
||||
|
||||
// Expose all loaded internal exported members to global scope.
|
||||
|
@ -1,26 +1,9 @@
|
||||
/* globals expect, it, describe, combineUrl, Dict, isDict, Name, PDFJS,
|
||||
stringToPDFString, isExternalLinkTargetSet, LinkTarget,
|
||||
removeNullCharacters, getFilenameFromUrl */
|
||||
stringToPDFString, removeNullCharacters */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('util', function() {
|
||||
describe('getFilenameFromUrl', function() {
|
||||
it('should get the filename from an absolute URL', function() {
|
||||
var url = 'http://server.org/filename.pdf';
|
||||
var result = getFilenameFromUrl(url);
|
||||
var expected = 'filename.pdf';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should get the filename from a relative URL', function() {
|
||||
var url = '../../filename.pdf';
|
||||
var result = getFilenameFromUrl(url);
|
||||
var expected = 'filename.pdf';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('combineUrl', function() {
|
||||
it('absolute url with protocol stays as is', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
@ -114,34 +97,6 @@ describe('util', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isExternalLinkTargetSet', function() {
|
||||
// Save the current state, to avoid interfering with other tests.
|
||||
var previousExternalLinkTarget = PDFJS.externalLinkTarget;
|
||||
|
||||
it('handles the predefined LinkTargets', function() {
|
||||
for (var key in LinkTarget) {
|
||||
var linkTarget = LinkTarget[key];
|
||||
PDFJS.externalLinkTarget = linkTarget;
|
||||
|
||||
expect(isExternalLinkTargetSet()).toEqual(!!linkTarget);
|
||||
}
|
||||
});
|
||||
|
||||
it('handles incorrect LinkTargets', function() {
|
||||
var targets = [true, '', false, -1, '_blank', null];
|
||||
|
||||
for (var i = 0, ii = targets.length; i < ii; i++) {
|
||||
var linkTarget = targets[i];
|
||||
PDFJS.externalLinkTarget = linkTarget;
|
||||
|
||||
expect(isExternalLinkTargetSet()).toEqual(false);
|
||||
}
|
||||
});
|
||||
|
||||
// Reset the state.
|
||||
PDFJS.externalLinkTarget = previousExternalLinkTarget;
|
||||
});
|
||||
|
||||
describe('removeNullCharacters', function() {
|
||||
it('should not modify string without null characters', function() {
|
||||
var str = 'string without null chars';
|
||||
|
Loading…
Reference in New Issue
Block a user