Bug 1516969 - Update pdf.js to version 2.1.145. r=bdahl

This commit is contained in:
Ryan VanderMeulen 2018-12-31 08:33:37 -05:00
Родитель d03099b507
Коммит e990c18296
5 изменённых файлов: 584 добавлений и 558 удалений

Просмотреть файл

@ -1,5 +1,5 @@
This is the PDF.js project output, https://github.com/mozilla/pdf.js This is the PDF.js project output, https://github.com/mozilla/pdf.js
Current extension version is: 2.1.132 Current extension version is: 2.1.145
Taken from upstream commit: d3868e1b Taken from upstream commit: d8f201ea

Просмотреть файл

@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict"; "use strict";
var pdfjsVersion = '2.1.132'; var pdfjsVersion = '2.1.145';
var pdfjsBuild = 'd3868e1b'; var pdfjsBuild = 'd8f201ea';
var pdfjsSharedUtil = __w_pdfjs_require__(1); var pdfjsSharedUtil = __w_pdfjs_require__(1);
@ -235,7 +235,7 @@ Object.defineProperty(exports, "URL", {
return _url_polyfill.URL; return _url_polyfill.URL;
} }
}); });
exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0; exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;
__w_pdfjs_require__(2); __w_pdfjs_require__(2);
@ -695,6 +695,19 @@ var MissingDataException = function MissingDataExceptionClosure() {
exports.MissingDataException = MissingDataException; exports.MissingDataException = MissingDataException;
const XRefEntryException = function XRefEntryExceptionClosure() {
function XRefEntryException(msg) {
this.message = msg;
}
XRefEntryException.prototype = new Error();
XRefEntryException.prototype.name = 'XRefEntryException';
XRefEntryException.constructor = XRefEntryException;
return XRefEntryException;
}();
exports.XRefEntryException = XRefEntryException;
var XRefParseException = function XRefParseExceptionClosure() { var XRefParseException = function XRefParseExceptionClosure() {
function XRefParseException(msg) { function XRefParseException(msg) {
this.message = msg; this.message = msg;
@ -5141,7 +5154,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
return worker.messageHandler.sendWithPromise('GetDocRequest', { return worker.messageHandler.sendWithPromise('GetDocRequest', {
docId, docId,
apiVersion: '2.1.132', apiVersion: '2.1.145',
source: { source: {
data: source.data, data: source.data,
url: source.url, url: source.url,
@ -6872,9 +6885,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
return InternalRenderTask; return InternalRenderTask;
}(); }();
const version = '2.1.132'; const version = '2.1.145';
exports.version = version; exports.version = version;
const build = 'd3868e1b'; const build = 'd8f201ea';
exports.build = build; exports.build = build;
/***/ }), /***/ }),
@ -8784,11 +8797,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
var name = fontObj.loadedName || 'sans-serif'; var name = fontObj.loadedName || 'sans-serif';
var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal'; var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
var italic = fontObj.italic ? 'italic' : 'normal'; var italic = fontObj.italic ? 'italic' : 'normal';
var typeface = '"' + name + '", ' + fontObj.fallbackName; var typeface = `"${name}", ${fontObj.fallbackName}`;
var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size; var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
this.current.fontSizeScale = size / browserFontSize; this.current.fontSizeScale = size / browserFontSize;
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface; this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
this.ctx.font = rule;
}, },
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) { setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
this.current.textRenderingMode = mode; this.current.textRenderingMode = mode;
@ -12344,14 +12356,14 @@ var renderTextLayer = function renderTextLayerClosure() {
if (textDivProperties.canvasWidth !== 0 && width > 0) { if (textDivProperties.canvasWidth !== 0 && width > 0) {
textDivProperties.scale = textDivProperties.canvasWidth / width; textDivProperties.scale = textDivProperties.canvasWidth / width;
transform = 'scaleX(' + textDivProperties.scale + ')'; transform = `scaleX(${textDivProperties.scale})`;
} }
if (textDivProperties.angle !== 0) { if (textDivProperties.angle !== 0) {
transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform; transform = `rotate(${textDivProperties.angle}deg) ${transform}`;
} }
if (transform !== '') { if (transform.length > 0) {
textDivProperties.originalTransform = transform; textDivProperties.originalTransform = transform;
textDiv.style.transform = transform; textDiv.style.transform = transform;
} }

Просмотреть файл

@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
"use strict"; "use strict";
var pdfjsVersion = '2.1.132'; var pdfjsVersion = '2.1.145';
var pdfjsBuild = 'd3868e1b'; var pdfjsBuild = 'd8f201ea';
var pdfjsCoreWorker = __w_pdfjs_require__(1); var pdfjsCoreWorker = __w_pdfjs_require__(1);
@ -375,7 +375,7 @@ var WorkerMessageHandler = {
var cancelXHRs = null; var cancelXHRs = null;
var WorkerTasks = []; var WorkerTasks = [];
let apiVersion = docParams.apiVersion; let apiVersion = docParams.apiVersion;
let workerVersion = '2.1.132'; let workerVersion = '2.1.145';
if (apiVersion !== workerVersion) { if (apiVersion !== workerVersion) {
throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`); throw new Error(`The API version "${apiVersion}" does not match ` + `the Worker version "${workerVersion}".`);
@ -403,28 +403,20 @@ var WorkerMessageHandler = {
WorkerTasks.splice(i, 1); WorkerTasks.splice(i, 1);
} }
function loadDocument(recoveryMode) { async function loadDocument(recoveryMode) {
var loadDocumentCapability = (0, _util.createPromiseCapability)(); await pdfManager.ensureDoc('checkHeader');
await pdfManager.ensureDoc('parseStartXRef');
await pdfManager.ensureDoc('parse', [recoveryMode]);
var parseSuccess = function parseSuccess() { if (!recoveryMode) {
Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]).then(function ([numPages, fingerprint]) { await pdfManager.ensureDoc('checkFirstPage');
loadDocumentCapability.resolve({ }
const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]);
return {
numPages, numPages,
fingerprint fingerprint
});
}, parseFailure);
}; };
var parseFailure = function parseFailure(e) {
loadDocumentCapability.reject(e);
};
pdfManager.ensureDoc('checkHeader', []).then(function () {
pdfManager.ensureDoc('parseStartXRef', []).then(function () {
pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
}, parseFailure);
}, parseFailure);
return loadDocumentCapability.promise;
} }
function getPdfManager(data, evaluatorOptions) { function getPdfManager(data, evaluatorOptions) {
@ -880,7 +872,7 @@ Object.defineProperty(exports, "URL", {
return _url_polyfill.URL; return _url_polyfill.URL;
} }
}); });
exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0; exports.createObjectURL = exports.FormatError = exports.XRefParseException = exports.XRefEntryException = exports.Util = exports.UnknownErrorException = exports.UnexpectedResponseException = exports.TextRenderingMode = exports.StreamType = exports.PermissionFlag = exports.PasswordResponses = exports.PasswordException = exports.NativeImageDecoding = exports.MissingPDFException = exports.MissingDataException = exports.InvalidPDFException = exports.AbortException = exports.CMapCompressionType = exports.ImageKind = exports.FontType = exports.AnnotationType = exports.AnnotationFlag = exports.AnnotationFieldFlag = exports.AnnotationBorderStyleType = exports.UNSUPPORTED_FEATURES = exports.VerbosityLevel = exports.OPS = exports.IDENTITY_MATRIX = exports.FONT_IDENTITY_MATRIX = void 0;
__w_pdfjs_require__(3); __w_pdfjs_require__(3);
@ -1340,6 +1332,19 @@ var MissingDataException = function MissingDataExceptionClosure() {
exports.MissingDataException = MissingDataException; exports.MissingDataException = MissingDataException;
const XRefEntryException = function XRefEntryExceptionClosure() {
function XRefEntryException(msg) {
this.message = msg;
}
XRefEntryException.prototype = new Error();
XRefEntryException.prototype.name = 'XRefEntryException';
XRefEntryException.constructor = XRefEntryException;
return XRefEntryException;
}();
exports.XRefEntryException = XRefEntryException;
var XRefParseException = function XRefParseExceptionClosure() { var XRefParseException = function XRefParseExceptionClosure() {
function XRefParseException(msg) { function XRefParseException(msg) {
this.message = msg; this.message = msg;
@ -6372,15 +6377,15 @@ var _evaluator = __w_pdfjs_require__(28);
var _function = __w_pdfjs_require__(42); var _function = __w_pdfjs_require__(42);
var Page = function PageClosure() { const DEFAULT_USER_UNIT = 1.0;
var DEFAULT_USER_UNIT = 1.0; const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
function isAnnotationRenderable(annotation, intent) { function isAnnotationRenderable(annotation, intent) {
return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable; return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
} }
function Page({ class Page {
constructor({
pdfManager, pdfManager,
xref, xref,
pageIndex, pageIndex,
@ -6400,8 +6405,8 @@ var Page = function PageClosure() {
this.pdfFunctionFactory = pdfFunctionFactory; this.pdfFunctionFactory = pdfFunctionFactory;
this.evaluatorOptions = pdfManager.evaluatorOptions; this.evaluatorOptions = pdfManager.evaluatorOptions;
this.resourcesPromise = null; this.resourcesPromise = null;
var uniquePrefix = 'p' + this.pageIndex + '_'; const uniquePrefix = `p${this.pageIndex}_`;
var idCounters = { const idCounters = {
obj: 0 obj: 0
}; };
this.idFactory = { this.idFactory = {
@ -6412,9 +6417,8 @@ var Page = function PageClosure() {
}; };
} }
Page.prototype = {
_getInheritableProperty(key, getArray = false) { _getInheritableProperty(key, getArray = false) {
let value = (0, _util.getInheritableProperty)({ const value = (0, _util.getInheritableProperty)({
dict: this.pageDict, dict: this.pageDict,
key, key,
getArray, getArray,
@ -6430,61 +6434,61 @@ var Page = function PageClosure() {
} }
return _primitives.Dict.merge(this.xref, value); return _primitives.Dict.merge(this.xref, value);
}, }
get content() { get content() {
return this.pageDict.get('Contents'); return this.pageDict.get('Contents');
}, }
get resources() { get resources() {
return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty); return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
}, }
get mediaBox() { get mediaBox() {
var mediaBox = this._getInheritableProperty('MediaBox', true); const mediaBox = this._getInheritableProperty('MediaBox', true);
if (!Array.isArray(mediaBox) || mediaBox.length !== 4) { if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX); return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
} }
return (0, _util.shadow)(this, 'mediaBox', mediaBox); return (0, _util.shadow)(this, 'mediaBox', mediaBox);
}, }
get cropBox() { get cropBox() {
var cropBox = this._getInheritableProperty('CropBox', true); const cropBox = this._getInheritableProperty('CropBox', true);
if (!Array.isArray(cropBox) || cropBox.length !== 4) { if (!Array.isArray(cropBox) || cropBox.length !== 4) {
return (0, _util.shadow)(this, 'cropBox', this.mediaBox); return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
} }
return (0, _util.shadow)(this, 'cropBox', cropBox); return (0, _util.shadow)(this, 'cropBox', cropBox);
}, }
get userUnit() { get userUnit() {
var obj = this.pageDict.get('UserUnit'); let obj = this.pageDict.get('UserUnit');
if (!(0, _util.isNum)(obj) || obj <= 0) { if (!(0, _util.isNum)(obj) || obj <= 0) {
obj = DEFAULT_USER_UNIT; obj = DEFAULT_USER_UNIT;
} }
return (0, _util.shadow)(this, 'userUnit', obj); return (0, _util.shadow)(this, 'userUnit', obj);
}, }
get view() { get view() {
var mediaBox = this.mediaBox, const mediaBox = this.mediaBox,
cropBox = this.cropBox; cropBox = this.cropBox;
if (mediaBox === cropBox) { if (mediaBox === cropBox) {
return (0, _util.shadow)(this, 'view', mediaBox); return (0, _util.shadow)(this, 'view', mediaBox);
} }
var intersection = _util.Util.intersect(cropBox, mediaBox); const intersection = _util.Util.intersect(cropBox, mediaBox);
return (0, _util.shadow)(this, 'view', intersection || mediaBox); return (0, _util.shadow)(this, 'view', intersection || mediaBox);
}, }
get rotate() { get rotate() {
var rotate = this._getInheritableProperty('Rotate') || 0; let rotate = this._getInheritableProperty('Rotate') || 0;
if (rotate % 90 !== 0) { if (rotate % 90 !== 0) {
rotate = 0; rotate = 0;
@ -6495,20 +6499,18 @@ var Page = function PageClosure() {
} }
return (0, _util.shadow)(this, 'rotate', rotate); return (0, _util.shadow)(this, 'rotate', rotate);
}, }
getContentStream: function Page_getContentStream() { getContentStream() {
var content = this.content; const content = this.content;
var stream; let stream;
if (Array.isArray(content)) { if (Array.isArray(content)) {
var xref = this.xref; const xref = this.xref;
var i, const streams = [];
n = content.length;
var streams = [];
for (i = 0; i < n; ++i) { for (const stream of content) {
streams.push(xref.fetchIfRef(content[i])); streams.push(xref.fetchIfRef(stream));
} }
stream = new _stream.StreamsSequenceStream(streams); stream = new _stream.StreamsSequenceStream(streams);
@ -6519,17 +6521,18 @@ var Page = function PageClosure() {
} }
return stream; return stream;
}, }
loadResources: function Page_loadResources(keys) {
loadResources(keys) {
if (!this.resourcesPromise) { if (!this.resourcesPromise) {
this.resourcesPromise = this.pdfManager.ensure(this, 'resources'); this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
} }
return this.resourcesPromise.then(() => { return this.resourcesPromise.then(() => {
let objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref); const objectLoader = new _obj.ObjectLoader(this.resources, keys, this.xref);
return objectLoader.load(); return objectLoader.load();
}); });
}, }
getOperatorList({ getOperatorList({
handler, handler,
@ -6537,9 +6540,9 @@ var Page = function PageClosure() {
intent, intent,
renderInteractiveForms renderInteractiveForms
}) { }) {
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream'); const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']); const resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
var partialEvaluator = new _evaluator.PartialEvaluator({ const partialEvaluator = new _evaluator.PartialEvaluator({
pdfManager: this.pdfManager, pdfManager: this.pdfManager,
xref: this.xref, xref: this.xref,
handler, handler,
@ -6550,9 +6553,9 @@ var Page = function PageClosure() {
options: this.evaluatorOptions, options: this.evaluatorOptions,
pdfFunctionFactory: this.pdfFunctionFactory pdfFunctionFactory: this.pdfFunctionFactory
}); });
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
var pageListPromise = dataPromises.then(([contentStream]) => { const pageListPromise = dataPromises.then(([contentStream]) => {
var opList = new _operator_list.OperatorList(intent, handler, this.pageIndex); const opList = new _operator_list.OperatorList(intent, handler, this.pageIndex);
handler.send('StartRenderPage', { handler.send('StartRenderPage', {
transparency: partialEvaluator.hasBlendModes(this.resources), transparency: partialEvaluator.hasBlendModes(this.resources),
pageIndex: this.pageIndex, pageIndex: this.pageIndex,
@ -6573,21 +6576,19 @@ var Page = function PageClosure() {
return pageOpList; return pageOpList;
} }
var i, const opListPromises = [];
ii,
opListPromises = [];
for (i = 0, ii = annotations.length; i < ii; i++) { for (const annotation of annotations) {
if (isAnnotationRenderable(annotations[i], intent)) { if (isAnnotationRenderable(annotation, intent)) {
opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms)); opListPromises.push(annotation.getOperatorList(partialEvaluator, task, renderInteractiveForms));
} }
} }
return Promise.all(opListPromises).then(function (opLists) { return Promise.all(opListPromises).then(function (opLists) {
pageOpList.addOp(_util.OPS.beginAnnotations, []); pageOpList.addOp(_util.OPS.beginAnnotations, []);
for (i = 0, ii = opLists.length; i < ii; i++) { for (const opList of opLists) {
pageOpList.addOpList(opLists[i]); pageOpList.addOpList(opList);
} }
pageOpList.addOp(_util.OPS.endAnnotations, []); pageOpList.addOp(_util.OPS.endAnnotations, []);
@ -6595,7 +6596,7 @@ var Page = function PageClosure() {
return pageOpList; return pageOpList;
}); });
}); });
}, }
extractTextContent({ extractTextContent({
handler, handler,
@ -6604,11 +6605,11 @@ var Page = function PageClosure() {
sink, sink,
combineTextItems combineTextItems
}) { }) {
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream'); const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']); const resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]); const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
return dataPromises.then(([contentStream]) => { return dataPromises.then(([contentStream]) => {
var partialEvaluator = new _evaluator.PartialEvaluator({ const partialEvaluator = new _evaluator.PartialEvaluator({
pdfManager: this.pdfManager, pdfManager: this.pdfManager,
xref: this.xref, xref: this.xref,
handler, handler,
@ -6628,11 +6629,11 @@ var Page = function PageClosure() {
sink sink
}); });
}); });
}, }
getAnnotationsData(intent) { getAnnotationsData(intent) {
return this._parsedAnnotations.then(function (annotations) { return this._parsedAnnotations.then(function (annotations) {
let annotationsData = []; const annotationsData = [];
for (let i = 0, ii = annotations.length; i < ii; i++) { for (let i = 0, ii = annotations.length; i < ii; i++) {
if (!intent || isAnnotationRenderable(annotations[i], intent)) { if (!intent || isAnnotationRenderable(annotations[i], intent)) {
@ -6642,11 +6643,11 @@ var Page = function PageClosure() {
return annotationsData; return annotationsData;
}); });
}, }
get annotations() { get annotations() {
return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []); return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []);
}, }
get _parsedAnnotations() { get _parsedAnnotations() {
const parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(() => { const parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(() => {
@ -6669,18 +6670,41 @@ var Page = function PageClosure() {
return (0, _util.shadow)(this, '_parsedAnnotations', parsedAnnotations); return (0, _util.shadow)(this, '_parsedAnnotations', parsedAnnotations);
} }
}; }
return Page;
}();
exports.Page = Page; exports.Page = Page;
const FINGERPRINT_FIRST_BYTES = 1024;
const EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
var PDFDocument = function PDFDocumentClosure() { function find(stream, needle, limit, backwards) {
var FINGERPRINT_FIRST_BYTES = 1024; const pos = stream.pos;
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00'; const end = stream.end;
function PDFDocument(pdfManager, arg) { if (pos + limit > end) {
var stream; limit = end - pos;
}
const strBuf = [];
for (let i = 0; i < limit; ++i) {
strBuf.push(String.fromCharCode(stream.getByte()));
}
const str = strBuf.join('');
stream.pos = pos;
const index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
if (index === -1) {
return false;
}
stream.pos += index;
return true;
}
class PDFDocument {
constructor(pdfManager, arg) {
let stream;
if ((0, _primitives.isStream)(arg)) { if ((0, _primitives.isStream)(arg)) {
stream = arg; stream = arg;
@ -6691,60 +6715,22 @@ var PDFDocument = function PDFDocumentClosure() {
} }
if (stream.length <= 0) { if (stream.length <= 0) {
throw new Error('PDFDocument: stream must have data'); throw new Error('PDFDocument: Stream must have data');
} }
this.pdfManager = pdfManager; this.pdfManager = pdfManager;
this.stream = stream; this.stream = stream;
this.xref = new _obj.XRef(stream, pdfManager); this.xref = new _obj.XRef(stream, pdfManager);
let evaluatorOptions = pdfManager.evaluatorOptions;
this.pdfFunctionFactory = new _function.PDFFunctionFactory({ this.pdfFunctionFactory = new _function.PDFFunctionFactory({
xref: this.xref, xref: this.xref,
isEvalSupported: evaluatorOptions.isEvalSupported isEvalSupported: pdfManager.evaluatorOptions.isEvalSupported
}); });
this._pagePromises = []; this._pagePromises = [];
} }
function find(stream, needle, limit, backwards) { parse(recoveryMode) {
var pos = stream.pos;
var end = stream.end;
var strBuf = [];
if (pos + limit > end) {
limit = end - pos;
}
for (var n = 0; n < limit; ++n) {
strBuf.push(String.fromCharCode(stream.getByte()));
}
var str = strBuf.join('');
stream.pos = pos;
var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
if (index === -1) {
return false;
}
stream.pos += index;
return true;
}
const DocumentInfoValidators = {
Title: _util.isString,
Author: _util.isString,
Subject: _util.isString,
Keywords: _util.isString,
Creator: _util.isString,
Producer: _util.isString,
CreationDate: _util.isString,
ModDate: _util.isString,
Trapped: _primitives.isName
};
PDFDocument.prototype = {
parse: function PDFDocument_parse(recoveryMode) {
this.setup(recoveryMode); this.setup(recoveryMode);
var version = this.catalog.catDict.get('Version'); const version = this.catalog.catDict.get('Version');
if ((0, _primitives.isName)(version)) { if ((0, _primitives.isName)(version)) {
this.pdfFormatVersion = version.name; this.pdfFormatVersion = version.name;
@ -6755,7 +6741,7 @@ var PDFDocument = function PDFDocumentClosure() {
if (this.acroForm) { if (this.acroForm) {
this.xfa = this.acroForm.get('XFA'); this.xfa = this.acroForm.get('XFA');
var fields = this.acroForm.get('Fields'); const fields = this.acroForm.get('Fields');
if ((!fields || !Array.isArray(fields) || fields.length === 0) && !this.xfa) { if ((!fields || !Array.isArray(fields) || fields.length === 0) && !this.xfa) {
this.acroForm = null; this.acroForm = null;
@ -6766,10 +6752,10 @@ var PDFDocument = function PDFDocumentClosure() {
throw ex; throw ex;
} }
(0, _util.info)('Something wrong with AcroForm entry'); (0, _util.info)('Cannot fetch AcroForm entry; assuming no AcroForms are present');
this.acroForm = null; this.acroForm = null;
} }
}, }
get linearization() { get linearization() {
let linearization = null; let linearization = null;
@ -6785,26 +6771,26 @@ var PDFDocument = function PDFDocumentClosure() {
} }
return (0, _util.shadow)(this, 'linearization', linearization); return (0, _util.shadow)(this, 'linearization', linearization);
}, }
get startXRef() { get startXRef() {
var stream = this.stream; const stream = this.stream;
var startXRef = 0; let startXRef = 0;
var linearization = this.linearization;
if (linearization) { if (this.linearization) {
stream.reset(); stream.reset();
if (find(stream, 'endobj', 1024)) { if (find(stream, 'endobj', 1024)) {
startXRef = stream.pos + 6; startXRef = stream.pos + 6;
} }
} else { } else {
var step = 1024; const step = 1024;
var found = false, const startXRefLength = 'startxref'.length;
let found = false,
pos = stream.end; pos = stream.end;
while (!found && pos > 0) { while (!found && pos > 0) {
pos -= step - 'startxref'.length; pos -= step - startXRefLength;
if (pos < 0) { if (pos < 0) {
pos = 0; pos = 0;
@ -6816,13 +6802,13 @@ var PDFDocument = function PDFDocumentClosure() {
if (found) { if (found) {
stream.skip(9); stream.skip(9);
var ch; let ch;
do { do {
ch = stream.getByte(); ch = stream.getByte();
} while ((0, _util.isSpace)(ch)); } while ((0, _util.isSpace)(ch));
var str = ''; let str = '';
while (ch >= 0x20 && ch <= 0x39) { while (ch >= 0x20 && ch <= 0x39) {
str += String.fromCharCode(ch); str += String.fromCharCode(ch);
@ -6838,20 +6824,23 @@ var PDFDocument = function PDFDocumentClosure() {
} }
return (0, _util.shadow)(this, 'startXRef', startXRef); return (0, _util.shadow)(this, 'startXRef', startXRef);
}, }
checkHeader: function PDFDocument_checkHeader() { checkHeader() {
var stream = this.stream; const stream = this.stream;
stream.reset(); stream.reset();
if (find(stream, '%PDF-', 1024)) { if (!find(stream, '%PDF-', 1024)) {
return;
}
stream.moveStart(); stream.moveStart();
var MAX_VERSION_LENGTH = 12; const MAX_PDF_VERSION_LENGTH = 12;
var version = '', let version = '',
ch; ch;
while ((ch = stream.getByte()) > 0x20) { while ((ch = stream.getByte()) > 0x20) {
if (version.length >= MAX_VERSION_LENGTH) { if (version.length >= MAX_PDF_VERSION_LENGTH) {
break; break;
} }
@ -6861,26 +6850,35 @@ var PDFDocument = function PDFDocumentClosure() {
if (!this.pdfFormatVersion) { if (!this.pdfFormatVersion) {
this.pdfFormatVersion = version.substring(5); this.pdfFormatVersion = version.substring(5);
} }
return;
} }
},
parseStartXRef: function PDFDocument_parseStartXRef() { parseStartXRef() {
var startXRef = this.startXRef; this.xref.setStartXRef(this.startXRef);
this.xref.setStartXRef(startXRef); }
},
setup: function PDFDocument_setup(recoveryMode) { setup(recoveryMode) {
this.xref.parse(recoveryMode); this.xref.parse(recoveryMode);
this.catalog = new _obj.Catalog(this.pdfManager, this.xref); this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
}, }
get numPages() { get numPages() {
var linearization = this.linearization; const linearization = this.linearization;
var num = linearization ? linearization.numPages : this.catalog.numPages; const num = linearization ? linearization.numPages : this.catalog.numPages;
return (0, _util.shadow)(this, 'numPages', num); return (0, _util.shadow)(this, 'numPages', num);
}, }
get documentInfo() { get documentInfo() {
const DocumentInfoValidators = {
Title: _util.isString,
Author: _util.isString,
Subject: _util.isString,
Keywords: _util.isString,
Creator: _util.isString,
Producer: _util.isString,
CreationDate: _util.isString,
ModDate: _util.isString,
Trapped: _primitives.isName
};
const docInfo = { const docInfo = {
PDFFormatVersion: this.pdfFormatVersion, PDFFormatVersion: this.pdfFormatVersion,
IsLinearized: !!this.linearization, IsLinearized: !!this.linearization,
@ -6900,7 +6898,7 @@ var PDFDocument = function PDFDocumentClosure() {
} }
if ((0, _primitives.isDict)(infoDict)) { if ((0, _primitives.isDict)(infoDict)) {
for (let key of infoDict.getKeys()) { for (const key of infoDict.getKeys()) {
const value = infoDict.get(key); const value = infoDict.get(key);
if (DocumentInfoValidators[key]) { if (DocumentInfoValidators[key]) {
@ -6931,13 +6929,11 @@ var PDFDocument = function PDFDocumentClosure() {
} }
return (0, _util.shadow)(this, 'documentInfo', docInfo); return (0, _util.shadow)(this, 'documentInfo', docInfo);
}, }
get fingerprint() { get fingerprint() {
var xref = this.xref, let hash;
hash, const idArray = this.xref.trailer.get('ID');
fileID = '';
var idArray = xref.trailer.get('ID');
if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) { if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
hash = (0, _util.stringToBytes)(idArray[0]); hash = (0, _util.stringToBytes)(idArray[0]);
@ -6949,13 +6945,15 @@ var PDFDocument = function PDFDocumentClosure() {
hash = (0, _crypto.calculateMD5)(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES); hash = (0, _crypto.calculateMD5)(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
} }
for (var i = 0, n = hash.length; i < n; i++) { let fingerprint = '';
var hex = hash[i].toString(16);
fileID += hex.length === 1 ? '0' + hex : hex; for (const hashPart of hash) {
const hex = hashPart.toString(16);
fingerprint += hex.length === 1 ? '0' + hex : hex;
} }
return (0, _util.shadow)(this, 'fingerprint', fileID); return (0, _util.shadow)(this, 'fingerprint', fingerprint);
}, }
_getLinearizationPage(pageIndex) { _getLinearizationPage(pageIndex) {
const { const {
@ -6978,7 +6976,7 @@ var PDFDocument = function PDFDocumentClosure() {
(0, _util.info)(reason); (0, _util.info)(reason);
return catalog.getPageDict(pageIndex); return catalog.getPageDict(pageIndex);
}); });
}, }
getPage(pageIndex) { getPage(pageIndex) {
if (this._pagePromises[pageIndex] !== undefined) { if (this._pagePromises[pageIndex] !== undefined) {
@ -7002,14 +7000,23 @@ var PDFDocument = function PDFDocumentClosure() {
pdfFunctionFactory: this.pdfFunctionFactory pdfFunctionFactory: this.pdfFunctionFactory
}); });
}); });
}, }
cleanup: function PDFDocument_cleanup() { checkFirstPage() {
return this.getPage(0).catch(reason => {
if (reason instanceof _util.XRefEntryException) {
this._pagePromises.length = 0;
this.cleanup();
throw new _util.XRefParseException();
}
});
}
cleanup() {
return this.catalog.cleanup(); return this.catalog.cleanup();
} }
};
return PDFDocument; }
}();
exports.PDFDocument = PDFDocument; exports.PDFDocument = PDFDocument;
@ -8503,7 +8510,7 @@ var XRef = function XRefClosure() {
if (xrefEntry.uncompressed) { if (xrefEntry.uncompressed) {
xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption); xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
} else { } else {
xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption); xrefEntry = this.fetchCompressed(ref, xrefEntry, suppressEncryption);
} }
if ((0, _primitives.isDict)(xrefEntry)) { if ((0, _primitives.isDict)(xrefEntry)) {
@ -8514,12 +8521,13 @@ var XRef = function XRefClosure() {
return xrefEntry; return xrefEntry;
}, },
fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
var gen = ref.gen; var gen = ref.gen;
var num = ref.num; var num = ref.num;
if (xrefEntry.gen !== gen) { if (xrefEntry.gen !== gen) {
throw new _util.FormatError('inconsistent generation in XRef'); throw new _util.XRefEntryException(`Inconsistent generation in XRef: ${ref}`);
} }
var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start); var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
@ -8537,7 +8545,7 @@ var XRef = function XRefClosure() {
} }
if (obj1 !== num || obj2 !== gen || !(0, _primitives.isCmd)(obj3)) { if (obj1 !== num || obj2 !== gen || !(0, _primitives.isCmd)(obj3)) {
throw new _util.FormatError('bad XRef entry'); throw new _util.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
} }
if (obj3.cmd !== 'obj') { if (obj3.cmd !== 'obj') {
@ -8549,7 +8557,7 @@ var XRef = function XRefClosure() {
} }
} }
throw new _util.FormatError('bad XRef entry'); throw new _util.XRefEntryException(`Bad (uncompressed) XRef entry: ${ref}`);
} }
if (this.encrypt && !suppressEncryption) { if (this.encrypt && !suppressEncryption) {
@ -8564,7 +8572,8 @@ var XRef = function XRefClosure() {
return xrefEntry; return xrefEntry;
}, },
fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
var tableOffset = xrefEntry.offset; var tableOffset = xrefEntry.offset;
var stream = this.fetch(new _primitives.Ref(tableOffset, 0)); var stream = this.fetch(new _primitives.Ref(tableOffset, 0));
@ -8619,7 +8628,7 @@ var XRef = function XRefClosure() {
xrefEntry = entries[xrefEntry.gen]; xrefEntry = entries[xrefEntry.gen];
if (xrefEntry === undefined) { if (xrefEntry === undefined) {
throw new _util.FormatError('bad XRef entry for compressed object'); throw new _util.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
} }
return xrefEntry; return xrefEntry;
@ -9240,13 +9249,11 @@ var Ref = function RefClosure() {
Ref.prototype = { Ref.prototype = {
toString: function Ref_toString() { toString: function Ref_toString() {
var str = this.num + 'R';
if (this.gen !== 0) { if (this.gen !== 0) {
str += this.gen; return `${this.num}R${this.gen}`;
} }
return str; return `${this.num}R`;
} }
}; };
return Ref; return Ref;
@ -21977,13 +21984,17 @@ class AnnotationBorderStyle {
} }
setWidth(width) { setWidth(width) {
if ((0, _primitives.isName)(width)) {
width = parseFloat(width.name);
}
if (Number.isInteger(width)) { if (Number.isInteger(width)) {
this.width = width; this.width = width;
} }
} }
setStyle(style) { setStyle(style) {
if (!style) { if (!(0, _primitives.isName)(style)) {
return; return;
} }

Просмотреть файл

@ -56,6 +56,8 @@
background-color: rgb(0, 100, 0); background-color: rgb(0, 100, 0);
} }
.textLayer ::-moz-selection { background: rgb(0,0,255); }
.textLayer ::selection { background: rgb(0,0,255); } .textLayer ::selection { background: rgb(0,0,255); }
.textLayer .endOfContent { .textLayer .endOfContent {
@ -1675,6 +1677,7 @@ html[dir='rtl'] .outlineItemToggler::before {
/* TODO: file FF bug to support ::-moz-selection:window-inactive /* TODO: file FF bug to support ::-moz-selection:window-inactive
so we can override the opaque grey background when the window is inactive; so we can override the opaque grey background when the window is inactive;
see https://bugzilla.mozilla.org/show_bug.cgi?id=706209 */ see https://bugzilla.mozilla.org/show_bug.cgi?id=706209 */
::-moz-selection { background: rgba(0,0,255,0.3); }
::selection { background: rgba(0,0,255,0.3); } ::selection { background: rgba(0,0,255,0.3); }
#errorWrapper { #errorWrapper {

Просмотреть файл

@ -20,7 +20,7 @@ origin:
# Human-readable identifier for this version/release # Human-readable identifier for this version/release
# Generally "version NNN", "tag SSS", "bookmark SSS" # Generally "version NNN", "tag SSS", "bookmark SSS"
release: version 2.1.132 release: version 2.1.145
# The package's license, where possible using the mnemonic from # The package's license, where possible using the mnemonic from
# https://spdx.org/licenses/ # https://spdx.org/licenses/