Browse Source

PDF.js version 1.8.314 - See mozilla/pdf.js@3adda80f9768b79b86e0bb2d51af186ce7adb83c

master v1.8.314
pdfjsbot 8 years ago
parent
commit
05baf8f1d9
  1. 2
      bower.json
  2. 197
      build/pdf.combined.js
  3. 12
      build/pdf.js
  4. 4
      build/pdf.min.js
  5. 187
      build/pdf.worker.js
  6. 36
      build/pdf.worker.min.js
  7. 14
      lib/core/annotation.js
  8. 79
      lib/core/document.js
  9. 76
      lib/core/evaluator.js
  10. 14
      lib/core/worker.js
  11. 4
      lib/display/api.js
  12. 4
      lib/display/global.js
  13. 4
      lib/pdf.js
  14. 4
      lib/pdf.worker.js
  15. 77
      lib/test/unit/evaluator_spec.js
  16. 2
      package.json

2
bower.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.312", "version": "1.8.314",
"main": [ "main": [
"build/pdf.js", "build/pdf.js",
"build/pdf.worker.js" "build/pdf.worker.js"

197
build/pdf.combined.js

@ -12773,8 +12773,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.312'; exports.version = version = '1.8.314';
exports.build = build = 'e81c067d'; exports.build = build = '3adda80f';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -18202,9 +18202,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D')); return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
}; };
function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) { function PartialEvaluator(_ref) {
var _this = this; var _this = this;
var pdfManager = _ref.pdfManager,
xref = _ref.xref,
handler = _ref.handler,
pageIndex = _ref.pageIndex,
idFactory = _ref.idFactory,
fontCache = _ref.fontCache,
builtInCMapCache = _ref.builtInCMapCache,
_ref$options = _ref.options,
options = _ref$options === undefined ? null : _ref$options;
this.pdfManager = pdfManager; this.pdfManager = pdfManager;
this.xref = xref; this.xref = xref;
this.handler = handler; this.handler = handler;
@ -18218,7 +18228,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (cachedCMap) { if (cachedCMap) {
return Promise.resolve(cachedCMap); return Promise.resolve(cachedCMap);
} }
return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) { return _this.handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
if (data.compressionType !== CMapCompressionType.NONE) { if (data.compressionType !== CMapCompressionType.NONE) {
_this.builtInCMapCache[name] = data; _this.builtInCMapCache[name] = data;
} }
@ -18384,7 +18394,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.beginGroup, [groupOptions]); operatorList.addOp(OPS.beginGroup, [groupOptions]);
} }
operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]); operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]);
return this.getOperatorList(xobj, task, dict.get('Resources') || resources, operatorList, initialState).then(function () { return this.getOperatorList({
stream: xobj,
task: task,
resources: dict.get('Resources') || resources,
operatorList: operatorList,
initialState: initialState
}).then(function () {
operatorList.addOp(OPS.paintFormXObjectEnd, []); operatorList.addOp(OPS.paintFormXObjectEnd, []);
if (group) { if (group) {
operatorList.addOp(OPS.endGroup, [groupOptions]); operatorList.addOp(OPS.endGroup, [groupOptions]);
@ -18488,7 +18504,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var tilingOpList = new OperatorList(); var tilingOpList = new OperatorList();
var resourcesArray = [patternDict.get('Resources'), resources]; var resourcesArray = [patternDict.get('Resources'), resources];
var patternResources = Dict.merge(this.xref, resourcesArray); var patternResources = Dict.merge(this.xref, resourcesArray);
return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () { return this.getOperatorList({
stream: pattern,
task: task,
resources: patternResources,
operatorList: tilingOpList
}).then(function () {
operatorList.addDependencies(tilingOpList.dependencies); operatorList.addDependencies(tilingOpList.dependencies);
operatorList.addOp(fn, getTilingPatternIR({ operatorList.addOp(fn, getTilingPatternIR({
fnArray: tilingOpList.fnArray, fnArray: tilingOpList.fnArray,
@ -18757,17 +18778,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(fn, args); operatorList.addOp(fn, args);
return Promise.resolve(); return Promise.resolve();
}, },
getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) { getOperatorList: function getOperatorList(_ref2) {
var _this7 = this; var _this7 = this;
var stream = _ref2.stream,
task = _ref2.task,
resources = _ref2.resources,
operatorList = _ref2.operatorList,
_ref2$initialState = _ref2.initialState,
initialState = _ref2$initialState === undefined ? null : _ref2$initialState;
resources = resources || Dict.empty;
initialState = initialState || new EvalState();
assert(operatorList, 'getOperatorList: missing "operatorList" parameter');
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
var imageCache = Object.create(null); var imageCache = Object.create(null);
assert(operatorList);
resources = resources || Dict.empty;
var xobjs = resources.get('XObject') || Dict.empty; var xobjs = resources.get('XObject') || Dict.empty;
var patterns = resources.get('Pattern') || Dict.empty; var patterns = resources.get('Pattern') || Dict.empty;
var stateManager = new StateManager(initialState || new EvalState()); var stateManager = new StateManager(initialState);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
var timeSlotManager = new TimeSlotManager(); var timeSlotManager = new TimeSlotManager();
function closePendingRestoreOPS(argument) { function closePendingRestoreOPS(argument) {
@ -19022,9 +19051,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) { getTextContent: function getTextContent(_ref3) {
var _this8 = this; var _this8 = this;
var stream = _ref3.stream,
task = _ref3.task,
resources = _ref3.resources,
_ref3$stateManager = _ref3.stateManager,
stateManager = _ref3$stateManager === undefined ? null : _ref3$stateManager,
_ref3$normalizeWhites = _ref3.normalizeWhitespace,
normalizeWhitespace = _ref3$normalizeWhites === undefined ? false : _ref3$normalizeWhites,
_ref3$combineTextItem = _ref3.combineTextItems,
combineTextItems = _ref3$combineTextItem === undefined ? false : _ref3$combineTextItem;
resources = resources || Dict.empty;
stateManager = stateManager || new StateManager(new TextState()); stateManager = stateManager || new StateManager(new TextState());
var WhitespaceRegexp = /\s/g; var WhitespaceRegexp = /\s/g;
var textContent = { var textContent = {
@ -19053,7 +19093,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var MULTI_SPACE_FACTOR_MAX = 4; var MULTI_SPACE_FACTOR_MAX = 4;
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
resources = xref.fetchIfRef(resources) || Dict.empty;
var xobjs = null; var xobjs = null;
var xobjsCache = Object.create(null); var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -19401,7 +19440,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (isArray(matrix) && matrix.length === 6) { if (isArray(matrix) && matrix.length === 6) {
xObjStateManager.transform(matrix); xObjStateManager.transform(matrix);
} }
next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, xObjStateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) { next(self.getTextContent({
stream: xobj,
task: task,
resources: xobj.dict.get('Resources') || resources,
stateManager: xObjStateManager,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
}).then(function (formTextContent) {
Util.appendToArray(textContent.items, formTextContent.items); Util.appendToArray(textContent.items, formTextContent.items);
Util.extendObj(textContent.styles, formTextContent.styles); Util.extendObj(textContent.styles, formTextContent.styles);
xobjsCache.key = name; xobjsCache.key = name;
@ -19444,6 +19490,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) { extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
var _this9 = this; var _this9 = this;
@ -20036,7 +20083,12 @@ var TranslatedFont = function TranslatedFontClosure() {
loadCharProcsPromise = loadCharProcsPromise.then(function () { loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key); var glyphStream = charProcs.get(key);
var operatorList = new OperatorList(); var operatorList = new OperatorList();
return type3Evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () { return type3Evaluator.getOperatorList({
stream: glyphStream,
task: task,
resources: fontResources,
operatorList: operatorList
}).then(function () {
charProcOperatorList[key] = operatorList.getIR(); charProcOperatorList[key] = operatorList.getIR();
parentOperatorList.addDependencies(operatorList.dependencies); parentOperatorList.addDependencies(operatorList.dependencies);
}).catch(function (reason) { }).catch(function (reason) {
@ -27534,7 +27586,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) { page.getOperatorList({
handler: handler,
task: task,
intent: data.intent,
renderInteractiveForms: data.renderInteractiveForms
}).then(function (operatorList) {
finishWorkerTask(task); finishWorkerTask(task);
info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength); info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
}, function (e) { }, function (e) {
@ -27576,7 +27633,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
return page.extractTextContent(handler, task, data.normalizeWhitespace, data.combineTextItems).then(function (textContent) { return page.extractTextContent({
handler: handler,
task: task,
normalizeWhitespace: data.normalizeWhitespace,
combineTextItems: data.combineTextItems
}).then(function (textContent) {
finishWorkerTask(task); finishWorkerTask(task);
info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms'); info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
return textContent; return textContent;
@ -28116,8 +28178,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.312'; PDFJS.version = '1.8.314';
PDFJS.build = 'e81c067d'; PDFJS.build = '3adda80f';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -28491,7 +28553,12 @@ var Annotation = function AnnotationClosure() {
return resourcesPromise.then(function (resources) { return resourcesPromise.then(function (resources) {
var opList = new OperatorList(); var opList = new OperatorList();
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]); opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
return evaluator.getOperatorList(_this.appearance, task, resources, opList).then(function () { return evaluator.getOperatorList({
stream: _this.appearance,
task: task,
resources: resources,
operatorList: opList
}).then(function () {
opList.addOp(OPS.endAnnotation, []); opList.addOp(OPS.endAnnotation, []);
_this.appearance.reset(); _this.appearance.reset();
return opList; return opList;
@ -28658,7 +28725,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
return Promise.resolve(operatorList); return Promise.resolve(operatorList);
} }
var stream = new Stream(stringToBytes(this.data.defaultAppearance)); var stream = new Stream(stringToBytes(this.data.defaultAppearance));
return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () { return evaluator.getOperatorList({
stream: stream,
task: task,
resources: this.fieldResources,
operatorList: operatorList
}).then(function () {
return operatorList; return operatorList;
}); });
} }
@ -30015,17 +30087,30 @@ var Page = function PageClosure() {
return objectLoader.load(); return objectLoader.load();
}); });
}, },
getOperatorList: function getOperatorList(handler, task, intent, renderInteractiveForms) { getOperatorList: function getOperatorList(_ref) {
var _this2 = this; var _this2 = this;
var pdfManager = this.pdfManager; var handler = _ref.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref.task,
intent = _ref.intent,
renderInteractiveForms = _ref.renderInteractiveForms;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
pdfManager: this.pdfManager,
xref: this.xref,
handler: handler,
pageIndex: this.pageIndex,
idFactory: this.idFactory,
fontCache: this.fontCache,
builtInCMapCache: this.builtInCMapCache,
options: this.evaluatorOptions
});
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
var pageListPromise = dataPromises.then(function (_ref) { var pageListPromise = dataPromises.then(function (_ref2) {
var _ref2 = _slicedToArray(_ref, 1), var _ref3 = _slicedToArray(_ref2, 1),
contentStream = _ref2[0]; contentStream = _ref3[0];
var opList = new OperatorList(intent, handler, _this2.pageIndex); var opList = new OperatorList(intent, handler, _this2.pageIndex);
handler.send('StartRenderPage', { handler.send('StartRenderPage', {
@ -30033,15 +30118,20 @@ var Page = function PageClosure() {
pageIndex: _this2.pageIndex, pageIndex: _this2.pageIndex,
intent: intent intent: intent
}); });
return partialEvaluator.getOperatorList(contentStream, task, _this2.resources, opList).then(function () { return partialEvaluator.getOperatorList({
stream: contentStream,
task: task,
resources: _this2.resources,
operatorList: opList
}).then(function () {
return opList; return opList;
}); });
}); });
var annotationsPromise = pdfManager.ensure(this, 'annotations'); var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref3) { return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref4) {
var _ref4 = _slicedToArray(_ref3, 2), var _ref5 = _slicedToArray(_ref4, 2),
pageOpList = _ref4[0], pageOpList = _ref5[0],
annotations = _ref4[1]; annotations = _ref5[1];
if (annotations.length === 0) { if (annotations.length === 0) {
pageOpList.flush(true); pageOpList.flush(true);
@ -30066,19 +30156,38 @@ var Page = function PageClosure() {
}); });
}); });
}, },
extractTextContent: function extractTextContent(handler, task, normalizeWhitespace, combineTextItems) { extractTextContent: function extractTextContent(_ref6) {
var _this3 = this; var _this3 = this;
var pdfManager = this.pdfManager; var handler = _ref6.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref6.task,
normalizeWhitespace = _ref6.normalizeWhitespace,
combineTextItems = _ref6.combineTextItems;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(function (_ref5) { return dataPromises.then(function (_ref7) {
var _ref6 = _slicedToArray(_ref5, 1), var _ref8 = _slicedToArray(_ref7, 1),
contentStream = _ref6[0]; contentStream = _ref8[0];
var partialEvaluator = new PartialEvaluator(pdfManager, _this3.xref, handler, _this3.pageIndex, _this3.idFactory, _this3.fontCache, _this3.builtInCMapCache, _this3.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
return partialEvaluator.getTextContent(contentStream, task, _this3.resources, null, normalizeWhitespace, combineTextItems); pdfManager: _this3.pdfManager,
xref: _this3.xref,
handler: handler,
pageIndex: _this3.pageIndex,
idFactory: _this3.idFactory,
fontCache: _this3.fontCache,
builtInCMapCache: _this3.builtInCMapCache,
options: _this3.evaluatorOptions
});
return partialEvaluator.getTextContent({
stream: contentStream,
task: task,
resources: _this3.resources,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
});
}); });
}, },
@ -43656,8 +43765,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.312'; var pdfjsVersion = '1.8.314';
var pdfjsBuild = 'e81c067d'; var pdfjsBuild = '3adda80f';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(26); var pdfjsDisplayGlobal = __w_pdfjs_require__(26);
var pdfjsDisplayAPI = __w_pdfjs_require__(10); var pdfjsDisplayAPI = __w_pdfjs_require__(10);

12
build/pdf.js

@ -3480,8 +3480,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.312'; exports.version = version = '1.8.314';
exports.build = build = 'e81c067d'; exports.build = build = '3adda80f';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;
@ -5453,8 +5453,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.312'; PDFJS.version = '1.8.314';
PDFJS.build = 'e81c067d'; PDFJS.build = '3adda80f';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {
@ -7949,8 +7949,8 @@ exports.TilingPattern = TilingPattern;
"use strict"; "use strict";
var pdfjsVersion = '1.8.312'; var pdfjsVersion = '1.8.314';
var pdfjsBuild = 'e81c067d'; var pdfjsBuild = '3adda80f';
var pdfjsSharedUtil = __w_pdfjs_require__(0); var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9); var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
var pdfjsDisplayAPI = __w_pdfjs_require__(3); var pdfjsDisplayAPI = __w_pdfjs_require__(3);

4
build/pdf.min.js vendored

File diff suppressed because one or more lines are too long

187
build/pdf.worker.js vendored

@ -11163,7 +11163,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) { page.getOperatorList({
handler: handler,
task: task,
intent: data.intent,
renderInteractiveForms: data.renderInteractiveForms
}).then(function (operatorList) {
finishWorkerTask(task); finishWorkerTask(task);
info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength); info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
}, function (e) { }, function (e) {
@ -11205,7 +11210,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
return page.extractTextContent(handler, task, data.normalizeWhitespace, data.combineTextItems).then(function (textContent) { return page.extractTextContent({
handler: handler,
task: task,
normalizeWhitespace: data.normalizeWhitespace,
combineTextItems: data.combineTextItems
}).then(function (textContent) {
finishWorkerTask(task); finishWorkerTask(task);
info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms'); info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
return textContent; return textContent;
@ -15222,9 +15232,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D')); return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
}; };
function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) { function PartialEvaluator(_ref) {
var _this = this; var _this = this;
var pdfManager = _ref.pdfManager,
xref = _ref.xref,
handler = _ref.handler,
pageIndex = _ref.pageIndex,
idFactory = _ref.idFactory,
fontCache = _ref.fontCache,
builtInCMapCache = _ref.builtInCMapCache,
_ref$options = _ref.options,
options = _ref$options === undefined ? null : _ref$options;
this.pdfManager = pdfManager; this.pdfManager = pdfManager;
this.xref = xref; this.xref = xref;
this.handler = handler; this.handler = handler;
@ -15238,7 +15258,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (cachedCMap) { if (cachedCMap) {
return Promise.resolve(cachedCMap); return Promise.resolve(cachedCMap);
} }
return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) { return _this.handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
if (data.compressionType !== CMapCompressionType.NONE) { if (data.compressionType !== CMapCompressionType.NONE) {
_this.builtInCMapCache[name] = data; _this.builtInCMapCache[name] = data;
} }
@ -15404,7 +15424,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.beginGroup, [groupOptions]); operatorList.addOp(OPS.beginGroup, [groupOptions]);
} }
operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]); operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]);
return this.getOperatorList(xobj, task, dict.get('Resources') || resources, operatorList, initialState).then(function () { return this.getOperatorList({
stream: xobj,
task: task,
resources: dict.get('Resources') || resources,
operatorList: operatorList,
initialState: initialState
}).then(function () {
operatorList.addOp(OPS.paintFormXObjectEnd, []); operatorList.addOp(OPS.paintFormXObjectEnd, []);
if (group) { if (group) {
operatorList.addOp(OPS.endGroup, [groupOptions]); operatorList.addOp(OPS.endGroup, [groupOptions]);
@ -15508,7 +15534,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var tilingOpList = new OperatorList(); var tilingOpList = new OperatorList();
var resourcesArray = [patternDict.get('Resources'), resources]; var resourcesArray = [patternDict.get('Resources'), resources];
var patternResources = Dict.merge(this.xref, resourcesArray); var patternResources = Dict.merge(this.xref, resourcesArray);
return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () { return this.getOperatorList({
stream: pattern,
task: task,
resources: patternResources,
operatorList: tilingOpList
}).then(function () {
operatorList.addDependencies(tilingOpList.dependencies); operatorList.addDependencies(tilingOpList.dependencies);
operatorList.addOp(fn, getTilingPatternIR({ operatorList.addOp(fn, getTilingPatternIR({
fnArray: tilingOpList.fnArray, fnArray: tilingOpList.fnArray,
@ -15777,17 +15808,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(fn, args); operatorList.addOp(fn, args);
return Promise.resolve(); return Promise.resolve();
}, },
getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) { getOperatorList: function getOperatorList(_ref2) {
var _this7 = this; var _this7 = this;
var stream = _ref2.stream,
task = _ref2.task,
resources = _ref2.resources,
operatorList = _ref2.operatorList,
_ref2$initialState = _ref2.initialState,
initialState = _ref2$initialState === undefined ? null : _ref2$initialState;
resources = resources || Dict.empty;
initialState = initialState || new EvalState();
assert(operatorList, 'getOperatorList: missing "operatorList" parameter');
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
var imageCache = Object.create(null); var imageCache = Object.create(null);
assert(operatorList);
resources = resources || Dict.empty;
var xobjs = resources.get('XObject') || Dict.empty; var xobjs = resources.get('XObject') || Dict.empty;
var patterns = resources.get('Pattern') || Dict.empty; var patterns = resources.get('Pattern') || Dict.empty;
var stateManager = new StateManager(initialState || new EvalState()); var stateManager = new StateManager(initialState);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
var timeSlotManager = new TimeSlotManager(); var timeSlotManager = new TimeSlotManager();
function closePendingRestoreOPS(argument) { function closePendingRestoreOPS(argument) {
@ -16042,9 +16081,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) { getTextContent: function getTextContent(_ref3) {
var _this8 = this; var _this8 = this;
var stream = _ref3.stream,
task = _ref3.task,
resources = _ref3.resources,
_ref3$stateManager = _ref3.stateManager,
stateManager = _ref3$stateManager === undefined ? null : _ref3$stateManager,
_ref3$normalizeWhites = _ref3.normalizeWhitespace,
normalizeWhitespace = _ref3$normalizeWhites === undefined ? false : _ref3$normalizeWhites,
_ref3$combineTextItem = _ref3.combineTextItems,
combineTextItems = _ref3$combineTextItem === undefined ? false : _ref3$combineTextItem;
resources = resources || Dict.empty;
stateManager = stateManager || new StateManager(new TextState()); stateManager = stateManager || new StateManager(new TextState());
var WhitespaceRegexp = /\s/g; var WhitespaceRegexp = /\s/g;
var textContent = { var textContent = {
@ -16073,7 +16123,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var MULTI_SPACE_FACTOR_MAX = 4; var MULTI_SPACE_FACTOR_MAX = 4;
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
resources = xref.fetchIfRef(resources) || Dict.empty;
var xobjs = null; var xobjs = null;
var xobjsCache = Object.create(null); var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -16421,7 +16470,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (isArray(matrix) && matrix.length === 6) { if (isArray(matrix) && matrix.length === 6) {
xObjStateManager.transform(matrix); xObjStateManager.transform(matrix);
} }
next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, xObjStateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) { next(self.getTextContent({
stream: xobj,
task: task,
resources: xobj.dict.get('Resources') || resources,
stateManager: xObjStateManager,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
}).then(function (formTextContent) {
Util.appendToArray(textContent.items, formTextContent.items); Util.appendToArray(textContent.items, formTextContent.items);
Util.extendObj(textContent.styles, formTextContent.styles); Util.extendObj(textContent.styles, formTextContent.styles);
xobjsCache.key = name; xobjsCache.key = name;
@ -16464,6 +16520,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) { extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
var _this9 = this; var _this9 = this;
@ -17056,7 +17113,12 @@ var TranslatedFont = function TranslatedFontClosure() {
loadCharProcsPromise = loadCharProcsPromise.then(function () { loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key); var glyphStream = charProcs.get(key);
var operatorList = new OperatorList(); var operatorList = new OperatorList();
return type3Evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () { return type3Evaluator.getOperatorList({
stream: glyphStream,
task: task,
resources: fontResources,
operatorList: operatorList
}).then(function () {
charProcOperatorList[key] = operatorList.getIR(); charProcOperatorList[key] = operatorList.getIR();
parentOperatorList.addDependencies(operatorList.dependencies); parentOperatorList.addDependencies(operatorList.dependencies);
}).catch(function (reason) { }).catch(function (reason) {
@ -24733,7 +24795,12 @@ var Annotation = function AnnotationClosure() {
return resourcesPromise.then(function (resources) { return resourcesPromise.then(function (resources) {
var opList = new OperatorList(); var opList = new OperatorList();
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]); opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
return evaluator.getOperatorList(_this.appearance, task, resources, opList).then(function () { return evaluator.getOperatorList({
stream: _this.appearance,
task: task,
resources: resources,
operatorList: opList
}).then(function () {
opList.addOp(OPS.endAnnotation, []); opList.addOp(OPS.endAnnotation, []);
_this.appearance.reset(); _this.appearance.reset();
return opList; return opList;
@ -24900,7 +24967,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
return Promise.resolve(operatorList); return Promise.resolve(operatorList);
} }
var stream = new Stream(stringToBytes(this.data.defaultAppearance)); var stream = new Stream(stringToBytes(this.data.defaultAppearance));
return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () { return evaluator.getOperatorList({
stream: stream,
task: task,
resources: this.fieldResources,
operatorList: operatorList
}).then(function () {
return operatorList; return operatorList;
}); });
} }
@ -26257,17 +26329,30 @@ var Page = function PageClosure() {
return objectLoader.load(); return objectLoader.load();
}); });
}, },
getOperatorList: function getOperatorList(handler, task, intent, renderInteractiveForms) { getOperatorList: function getOperatorList(_ref) {
var _this2 = this; var _this2 = this;
var pdfManager = this.pdfManager; var handler = _ref.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref.task,
intent = _ref.intent,
renderInteractiveForms = _ref.renderInteractiveForms;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
pdfManager: this.pdfManager,
xref: this.xref,
handler: handler,
pageIndex: this.pageIndex,
idFactory: this.idFactory,
fontCache: this.fontCache,
builtInCMapCache: this.builtInCMapCache,
options: this.evaluatorOptions
});
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
var pageListPromise = dataPromises.then(function (_ref) { var pageListPromise = dataPromises.then(function (_ref2) {
var _ref2 = _slicedToArray(_ref, 1), var _ref3 = _slicedToArray(_ref2, 1),
contentStream = _ref2[0]; contentStream = _ref3[0];
var opList = new OperatorList(intent, handler, _this2.pageIndex); var opList = new OperatorList(intent, handler, _this2.pageIndex);
handler.send('StartRenderPage', { handler.send('StartRenderPage', {
@ -26275,15 +26360,20 @@ var Page = function PageClosure() {
pageIndex: _this2.pageIndex, pageIndex: _this2.pageIndex,
intent: intent intent: intent
}); });
return partialEvaluator.getOperatorList(contentStream, task, _this2.resources, opList).then(function () { return partialEvaluator.getOperatorList({
stream: contentStream,
task: task,
resources: _this2.resources,
operatorList: opList
}).then(function () {
return opList; return opList;
}); });
}); });
var annotationsPromise = pdfManager.ensure(this, 'annotations'); var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref3) { return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref4) {
var _ref4 = _slicedToArray(_ref3, 2), var _ref5 = _slicedToArray(_ref4, 2),
pageOpList = _ref4[0], pageOpList = _ref5[0],
annotations = _ref4[1]; annotations = _ref5[1];
if (annotations.length === 0) { if (annotations.length === 0) {
pageOpList.flush(true); pageOpList.flush(true);
@ -26308,19 +26398,38 @@ var Page = function PageClosure() {
}); });
}); });
}, },
extractTextContent: function extractTextContent(handler, task, normalizeWhitespace, combineTextItems) { extractTextContent: function extractTextContent(_ref6) {
var _this3 = this; var _this3 = this;
var pdfManager = this.pdfManager; var handler = _ref6.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref6.task,
normalizeWhitespace = _ref6.normalizeWhitespace,
combineTextItems = _ref6.combineTextItems;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(function (_ref5) { return dataPromises.then(function (_ref7) {
var _ref6 = _slicedToArray(_ref5, 1), var _ref8 = _slicedToArray(_ref7, 1),
contentStream = _ref6[0]; contentStream = _ref8[0];
var partialEvaluator = new PartialEvaluator(pdfManager, _this3.xref, handler, _this3.pageIndex, _this3.idFactory, _this3.fontCache, _this3.builtInCMapCache, _this3.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
return partialEvaluator.getTextContent(contentStream, task, _this3.resources, null, normalizeWhitespace, combineTextItems); pdfManager: _this3.pdfManager,
xref: _this3.xref,
handler: handler,
pageIndex: _this3.pageIndex,
idFactory: _this3.idFactory,
fontCache: _this3.fontCache,
builtInCMapCache: _this3.builtInCMapCache,
options: _this3.evaluatorOptions
});
return partialEvaluator.getTextContent({
stream: contentStream,
task: task,
resources: _this3.resources,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
});
}); });
}, },
@ -37022,8 +37131,8 @@ exports.Type1Parser = Type1Parser;
"use strict"; "use strict";
var pdfjsVersion = '1.8.312'; var pdfjsVersion = '1.8.314';
var pdfjsBuild = 'e81c067d'; var pdfjsBuild = '3adda80f';
var pdfjsCoreWorker = __w_pdfjs_require__(8); var pdfjsCoreWorker = __w_pdfjs_require__(8);
{ {
__w_pdfjs_require__(19); __w_pdfjs_require__(19);

36
build/pdf.worker.min.js vendored

File diff suppressed because one or more lines are too long

14
lib/core/annotation.js

@ -275,7 +275,12 @@ var Annotation = function AnnotationClosure() {
return resourcesPromise.then(function (resources) { return resourcesPromise.then(function (resources) {
var opList = new OperatorList(); var opList = new OperatorList();
opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]); opList.addOp(OPS.beginAnnotation, [data.rect, transform, matrix]);
return evaluator.getOperatorList(_this.appearance, task, resources, opList).then(function () { return evaluator.getOperatorList({
stream: _this.appearance,
task: task,
resources: resources,
operatorList: opList
}).then(function () {
opList.addOp(OPS.endAnnotation, []); opList.addOp(OPS.endAnnotation, []);
_this.appearance.reset(); _this.appearance.reset();
return opList; return opList;
@ -442,7 +447,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
return Promise.resolve(operatorList); return Promise.resolve(operatorList);
} }
var stream = new Stream(stringToBytes(this.data.defaultAppearance)); var stream = new Stream(stringToBytes(this.data.defaultAppearance));
return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () { return evaluator.getOperatorList({
stream: stream,
task: task,
resources: this.fieldResources,
operatorList: operatorList
}).then(function () {
return operatorList; return operatorList;
}); });
} }

79
lib/core/document.js

@ -187,17 +187,30 @@ var Page = function PageClosure() {
return objectLoader.load(); return objectLoader.load();
}); });
}, },
getOperatorList: function getOperatorList(handler, task, intent, renderInteractiveForms) { getOperatorList: function getOperatorList(_ref) {
var _this2 = this; var _this2 = this;
var pdfManager = this.pdfManager; var handler = _ref.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref.task,
intent = _ref.intent,
renderInteractiveForms = _ref.renderInteractiveForms;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.builtInCMapCache, this.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
pdfManager: this.pdfManager,
xref: this.xref,
handler: handler,
pageIndex: this.pageIndex,
idFactory: this.idFactory,
fontCache: this.fontCache,
builtInCMapCache: this.builtInCMapCache,
options: this.evaluatorOptions
});
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
var pageListPromise = dataPromises.then(function (_ref) { var pageListPromise = dataPromises.then(function (_ref2) {
var _ref2 = _slicedToArray(_ref, 1), var _ref3 = _slicedToArray(_ref2, 1),
contentStream = _ref2[0]; contentStream = _ref3[0];
var opList = new OperatorList(intent, handler, _this2.pageIndex); var opList = new OperatorList(intent, handler, _this2.pageIndex);
handler.send('StartRenderPage', { handler.send('StartRenderPage', {
@ -205,15 +218,20 @@ var Page = function PageClosure() {
pageIndex: _this2.pageIndex, pageIndex: _this2.pageIndex,
intent: intent intent: intent
}); });
return partialEvaluator.getOperatorList(contentStream, task, _this2.resources, opList).then(function () { return partialEvaluator.getOperatorList({
stream: contentStream,
task: task,
resources: _this2.resources,
operatorList: opList
}).then(function () {
return opList; return opList;
}); });
}); });
var annotationsPromise = pdfManager.ensure(this, 'annotations'); var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref3) { return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref4) {
var _ref4 = _slicedToArray(_ref3, 2), var _ref5 = _slicedToArray(_ref4, 2),
pageOpList = _ref4[0], pageOpList = _ref5[0],
annotations = _ref4[1]; annotations = _ref5[1];
if (annotations.length === 0) { if (annotations.length === 0) {
pageOpList.flush(true); pageOpList.flush(true);
@ -238,19 +256,38 @@ var Page = function PageClosure() {
}); });
}); });
}, },
extractTextContent: function extractTextContent(handler, task, normalizeWhitespace, combineTextItems) { extractTextContent: function extractTextContent(_ref6) {
var _this3 = this; var _this3 = this;
var pdfManager = this.pdfManager; var handler = _ref6.handler,
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []); task = _ref6.task,
normalizeWhitespace = _ref6.normalizeWhitespace,
combineTextItems = _ref6.combineTextItems;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']); var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(function (_ref5) { return dataPromises.then(function (_ref7) {
var _ref6 = _slicedToArray(_ref5, 1), var _ref8 = _slicedToArray(_ref7, 1),
contentStream = _ref6[0]; contentStream = _ref8[0];
var partialEvaluator = new PartialEvaluator(pdfManager, _this3.xref, handler, _this3.pageIndex, _this3.idFactory, _this3.fontCache, _this3.builtInCMapCache, _this3.evaluatorOptions); var partialEvaluator = new PartialEvaluator({
return partialEvaluator.getTextContent(contentStream, task, _this3.resources, null, normalizeWhitespace, combineTextItems); pdfManager: _this3.pdfManager,
xref: _this3.xref,
handler: handler,
pageIndex: _this3.pageIndex,
idFactory: _this3.idFactory,
fontCache: _this3.fontCache,
builtInCMapCache: _this3.builtInCMapCache,
options: _this3.evaluatorOptions
});
return partialEvaluator.getTextContent({
stream: contentStream,
task: task,
resources: _this3.resources,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
});
}); });
}, },

76
lib/core/evaluator.js

@ -137,9 +137,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res); var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D')); return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
}; };
function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, builtInCMapCache, options) { function PartialEvaluator(_ref) {
var _this = this; var _this = this;
var pdfManager = _ref.pdfManager,
xref = _ref.xref,
handler = _ref.handler,
pageIndex = _ref.pageIndex,
idFactory = _ref.idFactory,
fontCache = _ref.fontCache,
builtInCMapCache = _ref.builtInCMapCache,
_ref$options = _ref.options,
options = _ref$options === undefined ? null : _ref$options;
this.pdfManager = pdfManager; this.pdfManager = pdfManager;
this.xref = xref; this.xref = xref;
this.handler = handler; this.handler = handler;
@ -153,7 +163,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (cachedCMap) { if (cachedCMap) {
return Promise.resolve(cachedCMap); return Promise.resolve(cachedCMap);
} }
return handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) { return _this.handler.sendWithPromise('FetchBuiltInCMap', { name: name }).then(function (data) {
if (data.compressionType !== CMapCompressionType.NONE) { if (data.compressionType !== CMapCompressionType.NONE) {
_this.builtInCMapCache[name] = data; _this.builtInCMapCache[name] = data;
} }
@ -319,7 +329,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.beginGroup, [groupOptions]); operatorList.addOp(OPS.beginGroup, [groupOptions]);
} }
operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]); operatorList.addOp(OPS.paintFormXObjectBegin, [matrix, bbox]);
return this.getOperatorList(xobj, task, dict.get('Resources') || resources, operatorList, initialState).then(function () { return this.getOperatorList({
stream: xobj,
task: task,
resources: dict.get('Resources') || resources,
operatorList: operatorList,
initialState: initialState
}).then(function () {
operatorList.addOp(OPS.paintFormXObjectEnd, []); operatorList.addOp(OPS.paintFormXObjectEnd, []);
if (group) { if (group) {
operatorList.addOp(OPS.endGroup, [groupOptions]); operatorList.addOp(OPS.endGroup, [groupOptions]);
@ -423,7 +439,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var tilingOpList = new OperatorList(); var tilingOpList = new OperatorList();
var resourcesArray = [patternDict.get('Resources'), resources]; var resourcesArray = [patternDict.get('Resources'), resources];
var patternResources = Dict.merge(this.xref, resourcesArray); var patternResources = Dict.merge(this.xref, resourcesArray);
return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () { return this.getOperatorList({
stream: pattern,
task: task,
resources: patternResources,
operatorList: tilingOpList
}).then(function () {
operatorList.addDependencies(tilingOpList.dependencies); operatorList.addDependencies(tilingOpList.dependencies);
operatorList.addOp(fn, getTilingPatternIR({ operatorList.addOp(fn, getTilingPatternIR({
fnArray: tilingOpList.fnArray, fnArray: tilingOpList.fnArray,
@ -692,17 +713,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(fn, args); operatorList.addOp(fn, args);
return Promise.resolve(); return Promise.resolve();
}, },
getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) { getOperatorList: function getOperatorList(_ref2) {
var _this7 = this; var _this7 = this;
var stream = _ref2.stream,
task = _ref2.task,
resources = _ref2.resources,
operatorList = _ref2.operatorList,
_ref2$initialState = _ref2.initialState,
initialState = _ref2$initialState === undefined ? null : _ref2$initialState;
resources = resources || Dict.empty;
initialState = initialState || new EvalState();
assert(operatorList, 'getOperatorList: missing "operatorList" parameter');
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
var imageCache = Object.create(null); var imageCache = Object.create(null);
assert(operatorList);
resources = resources || Dict.empty;
var xobjs = resources.get('XObject') || Dict.empty; var xobjs = resources.get('XObject') || Dict.empty;
var patterns = resources.get('Pattern') || Dict.empty; var patterns = resources.get('Pattern') || Dict.empty;
var stateManager = new StateManager(initialState || new EvalState()); var stateManager = new StateManager(initialState);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
var timeSlotManager = new TimeSlotManager(); var timeSlotManager = new TimeSlotManager();
function closePendingRestoreOPS(argument) { function closePendingRestoreOPS(argument) {
@ -957,9 +986,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) { getTextContent: function getTextContent(_ref3) {
var _this8 = this; var _this8 = this;
var stream = _ref3.stream,
task = _ref3.task,
resources = _ref3.resources,
_ref3$stateManager = _ref3.stateManager,
stateManager = _ref3$stateManager === undefined ? null : _ref3$stateManager,
_ref3$normalizeWhites = _ref3.normalizeWhitespace,
normalizeWhitespace = _ref3$normalizeWhites === undefined ? false : _ref3$normalizeWhites,
_ref3$combineTextItem = _ref3.combineTextItems,
combineTextItems = _ref3$combineTextItem === undefined ? false : _ref3$combineTextItem;
resources = resources || Dict.empty;
stateManager = stateManager || new StateManager(new TextState()); stateManager = stateManager || new StateManager(new TextState());
var WhitespaceRegexp = /\s/g; var WhitespaceRegexp = /\s/g;
var textContent = { var textContent = {
@ -988,7 +1028,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var MULTI_SPACE_FACTOR_MAX = 4; var MULTI_SPACE_FACTOR_MAX = 4;
var self = this; var self = this;
var xref = this.xref; var xref = this.xref;
resources = xref.fetchIfRef(resources) || Dict.empty;
var xobjs = null; var xobjs = null;
var xobjsCache = Object.create(null); var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager); var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -1336,7 +1375,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (isArray(matrix) && matrix.length === 6) { if (isArray(matrix) && matrix.length === 6) {
xObjStateManager.transform(matrix); xObjStateManager.transform(matrix);
} }
next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, xObjStateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) { next(self.getTextContent({
stream: xobj,
task: task,
resources: xobj.dict.get('Resources') || resources,
stateManager: xObjStateManager,
normalizeWhitespace: normalizeWhitespace,
combineTextItems: combineTextItems
}).then(function (formTextContent) {
Util.appendToArray(textContent.items, formTextContent.items); Util.appendToArray(textContent.items, formTextContent.items);
Util.extendObj(textContent.styles, formTextContent.styles); Util.extendObj(textContent.styles, formTextContent.styles);
xobjsCache.key = name; xobjsCache.key = name;
@ -1379,6 +1425,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason; throw reason;
}); });
}, },
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) { extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
var _this9 = this; var _this9 = this;
@ -1971,7 +2018,12 @@ var TranslatedFont = function TranslatedFontClosure() {
loadCharProcsPromise = loadCharProcsPromise.then(function () { loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key); var glyphStream = charProcs.get(key);
var operatorList = new OperatorList(); var operatorList = new OperatorList();
return type3Evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () { return type3Evaluator.getOperatorList({
stream: glyphStream,
task: task,
resources: fontResources,
operatorList: operatorList
}).then(function () {
charProcOperatorList[key] = operatorList.getIR(); charProcOperatorList[key] = operatorList.getIR();
parentOperatorList.addDependencies(operatorList.dependencies); parentOperatorList.addDependencies(operatorList.dependencies);
}).catch(function (reason) { }).catch(function (reason) {

14
lib/core/worker.js

@ -590,7 +590,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) { page.getOperatorList({
handler: handler,
task: task,
intent: data.intent,
renderInteractiveForms: data.renderInteractiveForms
}).then(function (operatorList) {
finishWorkerTask(task); finishWorkerTask(task);
info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength); info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
}, function (e) { }, function (e) {
@ -632,7 +637,12 @@ var WorkerMessageHandler = {
startWorkerTask(task); startWorkerTask(task);
var pageNum = pageIndex + 1; var pageNum = pageIndex + 1;
var start = Date.now(); var start = Date.now();
return page.extractTextContent(handler, task, data.normalizeWhitespace, data.combineTextItems).then(function (textContent) { return page.extractTextContent({
handler: handler,
task: task,
normalizeWhitespace: data.normalizeWhitespace,
combineTextItems: data.combineTextItems
}).then(function (textContent) {
finishWorkerTask(task); finishWorkerTask(task);
info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms'); info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
return textContent; return textContent;

4
lib/display/api.js

@ -1405,8 +1405,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}(); }();
var version, build; var version, build;
{ {
exports.version = version = '1.8.312'; exports.version = version = '1.8.314';
exports.build = build = 'e81c067d'; exports.build = build = '3adda80f';
} }
exports.getDocument = getDocument; exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort; exports.LoopbackPort = LoopbackPort;

4
lib/display/global.js

@ -39,8 +39,8 @@ if (!_util.globalScope.PDFJS) {
} }
var PDFJS = _util.globalScope.PDFJS; var PDFJS = _util.globalScope.PDFJS;
{ {
PDFJS.version = '1.8.312'; PDFJS.version = '1.8.314';
PDFJS.build = 'e81c067d'; PDFJS.build = '3adda80f';
} }
PDFJS.pdfBug = false; PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) { if (PDFJS.verbosity !== undefined) {

4
lib/pdf.js

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.312'; var pdfjsVersion = '1.8.314';
var pdfjsBuild = 'e81c067d'; var pdfjsBuild = '3adda80f';
var pdfjsSharedUtil = require('./shared/util.js'); var pdfjsSharedUtil = require('./shared/util.js');
var pdfjsDisplayGlobal = require('./display/global.js'); var pdfjsDisplayGlobal = require('./display/global.js');
var pdfjsDisplayAPI = require('./display/api.js'); var pdfjsDisplayAPI = require('./display/api.js');

4
lib/pdf.worker.js vendored

@ -14,8 +14,8 @@
*/ */
'use strict'; 'use strict';
var pdfjsVersion = '1.8.312'; var pdfjsVersion = '1.8.314';
var pdfjsBuild = 'e81c067d'; var pdfjsBuild = '3adda80f';
var pdfjsCoreWorker = require('./core/worker.js'); var pdfjsCoreWorker = require('./core/worker.js');
{ {
require('./core/network.js'); require('./core/network.js');

77
lib/test/unit/evaluator_spec.js

@ -54,15 +54,32 @@ describe('evaluator', function () {
function runOperatorListCheck(evaluator, stream, resources, callback) { function runOperatorListCheck(evaluator, stream, resources, callback) {
var result = new _evaluator.OperatorList(); var result = new _evaluator.OperatorList();
var task = new _worker.WorkerTask('OperatorListCheck'); var task = new _worker.WorkerTask('OperatorListCheck');
evaluator.getOperatorList(stream, task, resources, result).then(function () { evaluator.getOperatorList({
stream: stream,
task: task,
resources: resources,
operatorList: result
}).then(function () {
callback(result); callback(result);
}); });
} }
var partialEvaluator;
beforeAll(function (done) {
partialEvaluator = new _evaluator.PartialEvaluator({
pdfManager: new PdfManagerMock(),
xref: new XrefMock(),
handler: new HandlerMock(),
pageIndex: 0
});
done();
});
afterAll(function () {
partialEvaluator = null;
});
describe('splitCombinedOperations', function () { describe('splitCombinedOperations', function () {
it('should reject unknown operations', function (done) { it('should reject unknown operations', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('fTT'); var stream = new _stream.StringStream('fTT');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(1); expect(result.fnArray.length).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.fill); expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -71,9 +88,8 @@ describe('evaluator', function () {
}); });
}); });
it('should handle one operations', function (done) { it('should handle one operations', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('Q'); var stream = new _stream.StringStream('Q');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(1); expect(result.fnArray.length).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.restore); expect(result.fnArray[0]).toEqual(_util.OPS.restore);
@ -81,11 +97,10 @@ describe('evaluator', function () {
}); });
}); });
it('should handle two glued operations', function (done) { it('should handle two glued operations', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var resources = new ResourcesMock(); var resources = new ResourcesMock();
resources.Res1 = {}; resources.Res1 = {};
var stream = new _stream.StringStream('/Res1 DoQ'); var stream = new _stream.StringStream('/Res1 DoQ');
runOperatorListCheck(evaluator, stream, resources, function (result) { runOperatorListCheck(partialEvaluator, stream, resources, function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(2); expect(result.fnArray.length).toEqual(2);
expect(result.fnArray[0]).toEqual(_util.OPS.paintXObject); expect(result.fnArray[0]).toEqual(_util.OPS.paintXObject);
@ -94,9 +109,8 @@ describe('evaluator', function () {
}); });
}); });
it('should handle tree glued operations', function (done) { it('should handle tree glued operations', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('fff'); var stream = new _stream.StringStream('fff');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.fill); expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -106,11 +120,10 @@ describe('evaluator', function () {
}); });
}); });
it('should handle three glued operations #2', function (done) { it('should handle three glued operations #2', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var resources = new ResourcesMock(); var resources = new ResourcesMock();
resources.Res1 = {}; resources.Res1 = {};
var stream = new _stream.StringStream('B*Bf*'); var stream = new _stream.StringStream('B*Bf*');
runOperatorListCheck(evaluator, stream, resources, function (result) { runOperatorListCheck(partialEvaluator, stream, resources, function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.eoFillStroke); expect(result.fnArray[0]).toEqual(_util.OPS.eoFillStroke);
@ -120,9 +133,8 @@ describe('evaluator', function () {
}); });
}); });
it('should handle glued operations and operands', function (done) { it('should handle glued operations and operands', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('f5 Ts'); var stream = new _stream.StringStream('f5 Ts');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(2); expect(result.fnArray.length).toEqual(2);
expect(result.fnArray[0]).toEqual(_util.OPS.fill); expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -134,9 +146,8 @@ describe('evaluator', function () {
}); });
}); });
it('should handle glued operations and literals', function (done) { it('should handle glued operations and literals', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('trueifalserinulln'); var stream = new _stream.StringStream('trueifalserinulln');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.setFlatness); expect(result.fnArray[0]).toEqual(_util.OPS.setFlatness);
@ -154,9 +165,8 @@ describe('evaluator', function () {
}); });
describe('validateNumberOfArgs', function () { describe('validateNumberOfArgs', function () {
it('should execute if correct number of arguments', function (done) { it('should execute if correct number of arguments', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('5 1 d0'); var stream = new _stream.StringStream('5 1 d0');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray[0][0]).toEqual(5); expect(result.argsArray[0][0]).toEqual(5);
expect(result.argsArray[0][1]).toEqual(1); expect(result.argsArray[0][1]).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth); expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth);
@ -164,9 +174,8 @@ describe('evaluator', function () {
}); });
}); });
it('should execute if too many arguments', function (done) { it('should execute if too many arguments', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('5 1 4 d0'); var stream = new _stream.StringStream('5 1 4 d0');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray[0][0]).toEqual(1); expect(result.argsArray[0][0]).toEqual(1);
expect(result.argsArray[0][1]).toEqual(4); expect(result.argsArray[0][1]).toEqual(4);
expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth); expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth);
@ -174,9 +183,8 @@ describe('evaluator', function () {
}); });
}); });
it('should execute if nested commands', function (done) { it('should execute if nested commands', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('/F2 /GS2 gs 5.711 Tf'); var stream = new _stream.StringStream('/F2 /GS2 gs 5.711 Tf');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.fnArray.length).toEqual(3); expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.setGState); expect(result.fnArray[0]).toEqual(_util.OPS.setGState);
expect(result.fnArray[1]).toEqual(_util.OPS.dependency); expect(result.fnArray[1]).toEqual(_util.OPS.dependency);
@ -189,18 +197,16 @@ describe('evaluator', function () {
}); });
}); });
it('should skip if too few arguments', function (done) { it('should skip if too few arguments', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('5 d0'); var stream = new _stream.StringStream('5 d0');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray).toEqual([]); expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]); expect(result.fnArray).toEqual([]);
done(); done();
}); });
}); });
it('should close opened saves', function (done) { it('should close opened saves', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('qq'); var stream = new _stream.StringStream('qq');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(4); expect(result.fnArray.length).toEqual(4);
expect(result.fnArray[0]).toEqual(_util.OPS.save); expect(result.fnArray[0]).toEqual(_util.OPS.save);
@ -211,16 +217,14 @@ describe('evaluator', function () {
}); });
}); });
it('should skip paintXObject if name is missing', function (done) { it('should skip paintXObject if name is missing', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('/ Do'); var stream = new _stream.StringStream('/ Do');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) { runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray).toEqual([]); expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]); expect(result.fnArray).toEqual([]);
done(); done();
}); });
}); });
it('should skip paintXObject if subtype is PS', function (done) { it('should skip paintXObject if subtype is PS', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var xobjStreamDict = new _primitives.Dict(); var xobjStreamDict = new _primitives.Dict();
xobjStreamDict.set('Subtype', _primitives.Name.get('PS')); xobjStreamDict.set('Subtype', _primitives.Name.get('PS'));
var xobjStream = new _stream.Stream([], 0, 0, xobjStreamDict); var xobjStream = new _stream.Stream([], 0, 0, xobjStreamDict);
@ -229,7 +233,7 @@ describe('evaluator', function () {
var resources = new _primitives.Dict(); var resources = new _primitives.Dict();
resources.set('XObject', xobjs); resources.set('XObject', xobjs);
var stream = new _stream.StringStream('/Res1 Do'); var stream = new _stream.StringStream('/Res1 Do');
runOperatorListCheck(evaluator, stream, resources, function (result) { runOperatorListCheck(partialEvaluator, stream, resources, function (result) {
expect(result.argsArray).toEqual([]); expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]); expect(result.fnArray).toEqual([]);
done(); done();
@ -238,13 +242,17 @@ describe('evaluator', function () {
}); });
describe('thread control', function () { describe('thread control', function () {
it('should abort operator list parsing', function (done) { it('should abort operator list parsing', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('qqQQ'); var stream = new _stream.StringStream('qqQQ');
var resources = new ResourcesMock(); var resources = new ResourcesMock();
var result = new _evaluator.OperatorList(); var result = new _evaluator.OperatorList();
var task = new _worker.WorkerTask('OperatorListAbort'); var task = new _worker.WorkerTask('OperatorListAbort');
task.terminate(); task.terminate();
evaluator.getOperatorList(stream, task, resources, result).catch(function () { partialEvaluator.getOperatorList({
stream: stream,
task: task,
resources: resources,
operatorList: result
}).catch(function () {
expect(!!result.fnArray && !!result.argsArray).toEqual(true); expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(0); expect(result.fnArray.length).toEqual(0);
done(); done();
@ -252,11 +260,14 @@ describe('evaluator', function () {
}); });
it('should abort text parsing parsing', function (done) { it('should abort text parsing parsing', function (done) {
var resources = new ResourcesMock(); var resources = new ResourcesMock();
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('qqQQ'); var stream = new _stream.StringStream('qqQQ');
var task = new _worker.WorkerTask('TextContentAbort'); var task = new _worker.WorkerTask('TextContentAbort');
task.terminate(); task.terminate();
evaluator.getTextContent(stream, task, resources).catch(function () { partialEvaluator.getTextContent({
stream: stream,
task: task,
resources: resources
}).catch(function () {
expect(true).toEqual(true); expect(true).toEqual(true);
done(); done();
}); });

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "pdfjs-dist", "name": "pdfjs-dist",
"version": "1.8.312", "version": "1.8.314",
"main": "build/pdf.js", "main": "build/pdf.js",
"description": "Generic build of Mozilla's PDF.js library.", "description": "Generic build of Mozilla's PDF.js library.",
"keywords": [ "keywords": [

Loading…
Cancel
Save