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 @@ @@ -1,6 +1,6 @@
{
"name": "pdfjs-dist",
"version": "1.8.312",
"version": "1.8.314",
"main": [
"build/pdf.js",
"build/pdf.worker.js"

197
build/pdf.combined.js

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

12
build/pdf.js

@ -3480,8 +3480,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() { @@ -3480,8 +3480,8 @@ var _UnsupportedManager = function UnsupportedManagerClosure() {
}();
var version, build;
{
exports.version = version = '1.8.312';
exports.build = build = 'e81c067d';
exports.version = version = '1.8.314';
exports.build = build = '3adda80f';
}
exports.getDocument = getDocument;
exports.LoopbackPort = LoopbackPort;
@ -5453,8 +5453,8 @@ if (!_util.globalScope.PDFJS) { @@ -5453,8 +5453,8 @@ if (!_util.globalScope.PDFJS) {
}
var PDFJS = _util.globalScope.PDFJS;
{
PDFJS.version = '1.8.312';
PDFJS.build = 'e81c067d';
PDFJS.version = '1.8.314';
PDFJS.build = '3adda80f';
}
PDFJS.pdfBug = false;
if (PDFJS.verbosity !== undefined) {
@ -7949,8 +7949,8 @@ exports.TilingPattern = TilingPattern; @@ -7949,8 +7949,8 @@ exports.TilingPattern = TilingPattern;
"use strict";
var pdfjsVersion = '1.8.312';
var pdfjsBuild = 'e81c067d';
var pdfjsVersion = '1.8.314';
var pdfjsBuild = '3adda80f';
var pdfjsSharedUtil = __w_pdfjs_require__(0);
var pdfjsDisplayGlobal = __w_pdfjs_require__(9);
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 = { @@ -11163,7 +11163,12 @@ var WorkerMessageHandler = {
startWorkerTask(task);
var pageNum = pageIndex + 1;
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);
info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
}, function (e) {
@ -11205,7 +11210,12 @@ var WorkerMessageHandler = { @@ -11205,7 +11210,12 @@ var WorkerMessageHandler = {
startWorkerTask(task);
var pageNum = pageIndex + 1;
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);
info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
return textContent;
@ -15222,9 +15232,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -15222,9 +15232,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
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 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.xref = xref;
this.handler = handler;
@ -15238,7 +15258,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -15238,7 +15258,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (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) {
_this.builtInCMapCache[name] = data;
}
@ -15404,7 +15424,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -15404,7 +15424,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.beginGroup, [groupOptions]);
}
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, []);
if (group) {
operatorList.addOp(OPS.endGroup, [groupOptions]);
@ -15508,7 +15534,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -15508,7 +15534,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var tilingOpList = new OperatorList();
var resourcesArray = [patternDict.get('Resources'), resources];
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.addOp(fn, getTilingPatternIR({
fnArray: tilingOpList.fnArray,
@ -15777,17 +15808,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -15777,17 +15808,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(fn, args);
return Promise.resolve();
},
getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
getOperatorList: function getOperatorList(_ref2) {
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 xref = this.xref;
var imageCache = Object.create(null);
assert(operatorList);
resources = resources || Dict.empty;
var xobjs = resources.get('XObject') || 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 timeSlotManager = new TimeSlotManager();
function closePendingRestoreOPS(argument) {
@ -16042,9 +16081,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -16042,9 +16081,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason;
});
},
getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
getTextContent: function getTextContent(_ref3) {
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());
var WhitespaceRegexp = /\s/g;
var textContent = {
@ -16073,7 +16123,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -16073,7 +16123,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var MULTI_SPACE_FACTOR_MAX = 4;
var self = this;
var xref = this.xref;
resources = xref.fetchIfRef(resources) || Dict.empty;
var xobjs = null;
var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -16421,7 +16470,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -16421,7 +16470,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (isArray(matrix) && matrix.length === 6) {
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.extendObj(textContent.styles, formTextContent.styles);
xobjsCache.key = name;
@ -16464,6 +16520,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -16464,6 +16520,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason;
});
},
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
var _this9 = this;
@ -17056,7 +17113,12 @@ var TranslatedFont = function TranslatedFontClosure() { @@ -17056,7 +17113,12 @@ var TranslatedFont = function TranslatedFontClosure() {
loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key);
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();
parentOperatorList.addDependencies(operatorList.dependencies);
}).catch(function (reason) {
@ -24733,7 +24795,12 @@ var Annotation = function AnnotationClosure() { @@ -24733,7 +24795,12 @@ var Annotation = function AnnotationClosure() {
return resourcesPromise.then(function (resources) {
var opList = new OperatorList();
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, []);
_this.appearance.reset();
return opList;
@ -24900,7 +24967,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() { @@ -24900,7 +24967,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
return Promise.resolve(operatorList);
}
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;
});
}
@ -26257,17 +26329,30 @@ var Page = function PageClosure() { @@ -26257,17 +26329,30 @@ var Page = function PageClosure() {
return objectLoader.load();
});
},
getOperatorList: function getOperatorList(handler, task, intent, renderInteractiveForms) {
getOperatorList: function getOperatorList(_ref) {
var _this2 = this;
var pdfManager = this.pdfManager;
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
var handler = _ref.handler,
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 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 pageListPromise = dataPromises.then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 1),
contentStream = _ref2[0];
var pageListPromise = dataPromises.then(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 1),
contentStream = _ref3[0];
var opList = new OperatorList(intent, handler, _this2.pageIndex);
handler.send('StartRenderPage', {
@ -26275,15 +26360,20 @@ var Page = function PageClosure() { @@ -26275,15 +26360,20 @@ var Page = function PageClosure() {
pageIndex: _this2.pageIndex,
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;
});
});
var annotationsPromise = pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
pageOpList = _ref4[0],
annotations = _ref4[1];
var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
pageOpList = _ref5[0],
annotations = _ref5[1];
if (annotations.length === 0) {
pageOpList.flush(true);
@ -26308,19 +26398,38 @@ var Page = function PageClosure() { @@ -26308,19 +26398,38 @@ var Page = function PageClosure() {
});
});
},
extractTextContent: function extractTextContent(handler, task, normalizeWhitespace, combineTextItems) {
extractTextContent: function extractTextContent(_ref6) {
var _this3 = this;
var pdfManager = this.pdfManager;
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
var handler = _ref6.handler,
task = _ref6.task,
normalizeWhitespace = _ref6.normalizeWhitespace,
combineTextItems = _ref6.combineTextItems;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(function (_ref5) {
var _ref6 = _slicedToArray(_ref5, 1),
contentStream = _ref6[0];
return dataPromises.then(function (_ref7) {
var _ref8 = _slicedToArray(_ref7, 1),
contentStream = _ref8[0];
var partialEvaluator = new PartialEvaluator(pdfManager, _this3.xref, handler, _this3.pageIndex, _this3.idFactory, _this3.fontCache, _this3.builtInCMapCache, _this3.evaluatorOptions);
return partialEvaluator.getTextContent(contentStream, task, _this3.resources, null, normalizeWhitespace, combineTextItems);
var partialEvaluator = new PartialEvaluator({
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; @@ -37022,8 +37131,8 @@ exports.Type1Parser = Type1Parser;
"use strict";
var pdfjsVersion = '1.8.312';
var pdfjsBuild = 'e81c067d';
var pdfjsVersion = '1.8.314';
var pdfjsBuild = '3adda80f';
var pdfjsCoreWorker = __w_pdfjs_require__(8);
{
__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() { @@ -275,7 +275,12 @@ var Annotation = function AnnotationClosure() {
return resourcesPromise.then(function (resources) {
var opList = new OperatorList();
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, []);
_this.appearance.reset();
return opList;
@ -442,7 +447,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() { @@ -442,7 +447,12 @@ var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
return Promise.resolve(operatorList);
}
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;
});
}

79
lib/core/document.js

@ -187,17 +187,30 @@ var Page = function PageClosure() { @@ -187,17 +187,30 @@ var Page = function PageClosure() {
return objectLoader.load();
});
},
getOperatorList: function getOperatorList(handler, task, intent, renderInteractiveForms) {
getOperatorList: function getOperatorList(_ref) {
var _this2 = this;
var pdfManager = this.pdfManager;
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
var handler = _ref.handler,
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 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 pageListPromise = dataPromises.then(function (_ref) {
var _ref2 = _slicedToArray(_ref, 1),
contentStream = _ref2[0];
var pageListPromise = dataPromises.then(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 1),
contentStream = _ref3[0];
var opList = new OperatorList(intent, handler, _this2.pageIndex);
handler.send('StartRenderPage', {
@ -205,15 +218,20 @@ var Page = function PageClosure() { @@ -205,15 +218,20 @@ var Page = function PageClosure() {
pageIndex: _this2.pageIndex,
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;
});
});
var annotationsPromise = pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
pageOpList = _ref4[0],
annotations = _ref4[1];
var annotationsPromise = this.pdfManager.ensure(this, 'annotations');
return Promise.all([pageListPromise, annotationsPromise]).then(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
pageOpList = _ref5[0],
annotations = _ref5[1];
if (annotations.length === 0) {
pageOpList.flush(true);
@ -238,19 +256,38 @@ var Page = function PageClosure() { @@ -238,19 +256,38 @@ var Page = function PageClosure() {
});
});
},
extractTextContent: function extractTextContent(handler, task, normalizeWhitespace, combineTextItems) {
extractTextContent: function extractTextContent(_ref6) {
var _this3 = this;
var pdfManager = this.pdfManager;
var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
var handler = _ref6.handler,
task = _ref6.task,
normalizeWhitespace = _ref6.normalizeWhitespace,
combineTextItems = _ref6.combineTextItems;
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(function (_ref5) {
var _ref6 = _slicedToArray(_ref5, 1),
contentStream = _ref6[0];
return dataPromises.then(function (_ref7) {
var _ref8 = _slicedToArray(_ref7, 1),
contentStream = _ref8[0];
var partialEvaluator = new PartialEvaluator(pdfManager, _this3.xref, handler, _this3.pageIndex, _this3.idFactory, _this3.fontCache, _this3.builtInCMapCache, _this3.evaluatorOptions);
return partialEvaluator.getTextContent(contentStream, task, _this3.resources, null, normalizeWhitespace, combineTextItems);
var partialEvaluator = new PartialEvaluator({
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() { @@ -137,9 +137,19 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
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 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.xref = xref;
this.handler = handler;
@ -153,7 +163,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -153,7 +163,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (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) {
_this.builtInCMapCache[name] = data;
}
@ -319,7 +329,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -319,7 +329,13 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(OPS.beginGroup, [groupOptions]);
}
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, []);
if (group) {
operatorList.addOp(OPS.endGroup, [groupOptions]);
@ -423,7 +439,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -423,7 +439,12 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var tilingOpList = new OperatorList();
var resourcesArray = [patternDict.get('Resources'), resources];
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.addOp(fn, getTilingPatternIR({
fnArray: tilingOpList.fnArray,
@ -692,17 +713,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -692,17 +713,25 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
operatorList.addOp(fn, args);
return Promise.resolve();
},
getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
getOperatorList: function getOperatorList(_ref2) {
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 xref = this.xref;
var imageCache = Object.create(null);
assert(operatorList);
resources = resources || Dict.empty;
var xobjs = resources.get('XObject') || 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 timeSlotManager = new TimeSlotManager();
function closePendingRestoreOPS(argument) {
@ -957,9 +986,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -957,9 +986,20 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason;
});
},
getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
getTextContent: function getTextContent(_ref3) {
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());
var WhitespaceRegexp = /\s/g;
var textContent = {
@ -988,7 +1028,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -988,7 +1028,6 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
var MULTI_SPACE_FACTOR_MAX = 4;
var self = this;
var xref = this.xref;
resources = xref.fetchIfRef(resources) || Dict.empty;
var xobjs = null;
var xobjsCache = Object.create(null);
var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
@ -1336,7 +1375,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -1336,7 +1375,14 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
if (isArray(matrix) && matrix.length === 6) {
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.extendObj(textContent.styles, formTextContent.styles);
xobjsCache.key = name;
@ -1379,6 +1425,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() { @@ -1379,6 +1425,7 @@ var PartialEvaluator = function PartialEvaluatorClosure() {
throw reason;
});
},
extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, properties) {
var _this9 = this;
@ -1971,7 +2018,12 @@ var TranslatedFont = function TranslatedFontClosure() { @@ -1971,7 +2018,12 @@ var TranslatedFont = function TranslatedFontClosure() {
loadCharProcsPromise = loadCharProcsPromise.then(function () {
var glyphStream = charProcs.get(key);
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();
parentOperatorList.addDependencies(operatorList.dependencies);
}).catch(function (reason) {

14
lib/core/worker.js

@ -590,7 +590,12 @@ var WorkerMessageHandler = { @@ -590,7 +590,12 @@ var WorkerMessageHandler = {
startWorkerTask(task);
var pageNum = pageIndex + 1;
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);
info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
}, function (e) {
@ -632,7 +637,12 @@ var WorkerMessageHandler = { @@ -632,7 +637,12 @@ var WorkerMessageHandler = {
startWorkerTask(task);
var pageNum = pageIndex + 1;
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);
info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
return textContent;

4
lib/display/api.js

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

4
lib/display/global.js

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

4
lib/pdf.js

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

4
lib/pdf.worker.js vendored

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

77
lib/test/unit/evaluator_spec.js

@ -54,15 +54,32 @@ describe('evaluator', function () { @@ -54,15 +54,32 @@ describe('evaluator', function () {
function runOperatorListCheck(evaluator, stream, resources, callback) {
var result = new _evaluator.OperatorList();
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);
});
}
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 () {
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -71,9 +88,8 @@ describe('evaluator', function () { @@ -71,9 +88,8 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.restore);
@ -81,11 +97,10 @@ describe('evaluator', function () { @@ -81,11 +97,10 @@ describe('evaluator', function () {
});
});
it('should handle two glued operations', function (done) {
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var resources = new ResourcesMock();
resources.Res1 = {};
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.length).toEqual(2);
expect(result.fnArray[0]).toEqual(_util.OPS.paintXObject);
@ -94,9 +109,8 @@ describe('evaluator', function () { @@ -94,9 +109,8 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -106,11 +120,10 @@ describe('evaluator', function () { @@ -106,11 +120,10 @@ describe('evaluator', function () {
});
});
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();
resources.Res1 = {};
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.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.eoFillStroke);
@ -120,9 +133,8 @@ describe('evaluator', function () { @@ -120,9 +133,8 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(2);
expect(result.fnArray[0]).toEqual(_util.OPS.fill);
@ -134,9 +146,8 @@ describe('evaluator', function () { @@ -134,9 +146,8 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.setFlatness);
@ -154,9 +165,8 @@ describe('evaluator', function () { @@ -154,9 +165,8 @@ describe('evaluator', function () {
});
describe('validateNumberOfArgs', function () {
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');
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][1]).toEqual(1);
expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth);
@ -164,9 +174,8 @@ describe('evaluator', function () { @@ -164,9 +174,8 @@ describe('evaluator', function () {
});
});
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');
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][1]).toEqual(4);
expect(result.fnArray[0]).toEqual(_util.OPS.setCharWidth);
@ -174,9 +183,8 @@ describe('evaluator', function () { @@ -174,9 +183,8 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.fnArray.length).toEqual(3);
expect(result.fnArray[0]).toEqual(_util.OPS.setGState);
expect(result.fnArray[1]).toEqual(_util.OPS.dependency);
@ -189,18 +197,16 @@ describe('evaluator', function () { @@ -189,18 +197,16 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]);
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(4);
expect(result.fnArray[0]).toEqual(_util.OPS.save);
@ -211,16 +217,14 @@ describe('evaluator', function () { @@ -211,16 +217,14 @@ describe('evaluator', function () {
});
});
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');
runOperatorListCheck(evaluator, stream, new ResourcesMock(), function (result) {
runOperatorListCheck(partialEvaluator, stream, new ResourcesMock(), function (result) {
expect(result.argsArray).toEqual([]);
expect(result.fnArray).toEqual([]);
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();
xobjStreamDict.set('Subtype', _primitives.Name.get('PS'));
var xobjStream = new _stream.Stream([], 0, 0, xobjStreamDict);
@ -229,7 +233,7 @@ describe('evaluator', function () { @@ -229,7 +233,7 @@ describe('evaluator', function () {
var resources = new _primitives.Dict();
resources.set('XObject', xobjs);
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.fnArray).toEqual([]);
done();
@ -238,13 +242,17 @@ describe('evaluator', function () { @@ -238,13 +242,17 @@ describe('evaluator', function () {
});
describe('thread control', function () {
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 resources = new ResourcesMock();
var result = new _evaluator.OperatorList();
var task = new _worker.WorkerTask('OperatorListAbort');
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.length).toEqual(0);
done();
@ -252,11 +260,14 @@ describe('evaluator', function () { @@ -252,11 +260,14 @@ describe('evaluator', function () {
});
it('should abort text parsing parsing', function (done) {
var resources = new ResourcesMock();
var evaluator = new _evaluator.PartialEvaluator(new PdfManagerMock(), new XrefMock(), new HandlerMock(), 'prefix');
var stream = new _stream.StringStream('qqQQ');
var task = new _worker.WorkerTask('TextContentAbort');
task.terminate();
evaluator.getTextContent(stream, task, resources).catch(function () {
partialEvaluator.getTextContent({
stream: stream,
task: task,
resources: resources
}).catch(function () {
expect(true).toEqual(true);
done();
});

2
package.json

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

Loading…
Cancel
Save