зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1516969 - Update pdf.js to version 2.1.145. r=bdahl
This commit is contained in:
Родитель
d03099b507
Коммит
e990c18296
|
@ -1,5 +1,5 @@
|
|||
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";
|
||||
|
||||
|
||||
var pdfjsVersion = '2.1.132';
|
||||
var pdfjsBuild = 'd3868e1b';
|
||||
var pdfjsVersion = '2.1.145';
|
||||
var pdfjsBuild = 'd8f201ea';
|
||||
|
||||
var pdfjsSharedUtil = __w_pdfjs_require__(1);
|
||||
|
||||
|
@ -235,7 +235,7 @@ Object.defineProperty(exports, "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);
|
||||
|
||||
|
@ -695,6 +695,19 @@ var MissingDataException = function MissingDataExceptionClosure() {
|
|||
|
||||
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() {
|
||||
function XRefParseException(msg) {
|
||||
this.message = msg;
|
||||
|
@ -5141,7 +5154,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||
|
||||
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
||||
docId,
|
||||
apiVersion: '2.1.132',
|
||||
apiVersion: '2.1.145',
|
||||
source: {
|
||||
data: source.data,
|
||||
url: source.url,
|
||||
|
@ -6872,9 +6885,9 @@ const InternalRenderTask = function InternalRenderTaskClosure() {
|
|||
return InternalRenderTask;
|
||||
}();
|
||||
|
||||
const version = '2.1.132';
|
||||
const version = '2.1.145';
|
||||
exports.version = version;
|
||||
const build = 'd3868e1b';
|
||||
const build = 'd8f201ea';
|
||||
exports.build = build;
|
||||
|
||||
/***/ }),
|
||||
|
@ -8784,11 +8797,10 @@ var CanvasGraphics = function CanvasGraphicsClosure() {
|
|||
var name = fontObj.loadedName || 'sans-serif';
|
||||
var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : '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;
|
||||
this.current.fontSizeScale = size / browserFontSize;
|
||||
var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
|
||||
this.ctx.font = rule;
|
||||
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
||||
},
|
||||
setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
|
||||
this.current.textRenderingMode = mode;
|
||||
|
@ -12344,14 +12356,14 @@ var renderTextLayer = function renderTextLayerClosure() {
|
|||
|
||||
if (textDivProperties.canvasWidth !== 0 && width > 0) {
|
||||
textDivProperties.scale = textDivProperties.canvasWidth / width;
|
||||
transform = 'scaleX(' + textDivProperties.scale + ')';
|
||||
transform = `scaleX(${textDivProperties.scale})`;
|
||||
}
|
||||
|
||||
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;
|
||||
textDiv.style.transform = transform;
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
"use strict";
|
||||
|
||||
|
||||
var pdfjsVersion = '2.1.132';
|
||||
var pdfjsBuild = 'd3868e1b';
|
||||
var pdfjsVersion = '2.1.145';
|
||||
var pdfjsBuild = 'd8f201ea';
|
||||
|
||||
var pdfjsCoreWorker = __w_pdfjs_require__(1);
|
||||
|
||||
|
@ -375,7 +375,7 @@ var WorkerMessageHandler = {
|
|||
var cancelXHRs = null;
|
||||
var WorkerTasks = [];
|
||||
let apiVersion = docParams.apiVersion;
|
||||
let workerVersion = '2.1.132';
|
||||
let workerVersion = '2.1.145';
|
||||
|
||||
if (apiVersion !== 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);
|
||||
}
|
||||
|
||||
function loadDocument(recoveryMode) {
|
||||
var loadDocumentCapability = (0, _util.createPromiseCapability)();
|
||||
async function loadDocument(recoveryMode) {
|
||||
await pdfManager.ensureDoc('checkHeader');
|
||||
await pdfManager.ensureDoc('parseStartXRef');
|
||||
await pdfManager.ensureDoc('parse', [recoveryMode]);
|
||||
|
||||
var parseSuccess = function parseSuccess() {
|
||||
Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]).then(function ([numPages, fingerprint]) {
|
||||
loadDocumentCapability.resolve({
|
||||
if (!recoveryMode) {
|
||||
await pdfManager.ensureDoc('checkFirstPage');
|
||||
}
|
||||
|
||||
const [numPages, fingerprint] = await Promise.all([pdfManager.ensureDoc('numPages'), pdfManager.ensureDoc('fingerprint')]);
|
||||
return {
|
||||
numPages,
|
||||
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) {
|
||||
|
@ -880,7 +872,7 @@ Object.defineProperty(exports, "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);
|
||||
|
||||
|
@ -1340,6 +1332,19 @@ var MissingDataException = function MissingDataExceptionClosure() {
|
|||
|
||||
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() {
|
||||
function XRefParseException(msg) {
|
||||
this.message = msg;
|
||||
|
@ -6372,15 +6377,15 @@ var _evaluator = __w_pdfjs_require__(28);
|
|||
|
||||
var _function = __w_pdfjs_require__(42);
|
||||
|
||||
var Page = function PageClosure() {
|
||||
var DEFAULT_USER_UNIT = 1.0;
|
||||
var LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
||||
const DEFAULT_USER_UNIT = 1.0;
|
||||
const LETTER_SIZE_MEDIABOX = [0, 0, 612, 792];
|
||||
|
||||
function isAnnotationRenderable(annotation, intent) {
|
||||
return intent === 'display' && annotation.viewable || intent === 'print' && annotation.printable;
|
||||
}
|
||||
|
||||
function Page({
|
||||
class Page {
|
||||
constructor({
|
||||
pdfManager,
|
||||
xref,
|
||||
pageIndex,
|
||||
|
@ -6400,8 +6405,8 @@ var Page = function PageClosure() {
|
|||
this.pdfFunctionFactory = pdfFunctionFactory;
|
||||
this.evaluatorOptions = pdfManager.evaluatorOptions;
|
||||
this.resourcesPromise = null;
|
||||
var uniquePrefix = 'p' + this.pageIndex + '_';
|
||||
var idCounters = {
|
||||
const uniquePrefix = `p${this.pageIndex}_`;
|
||||
const idCounters = {
|
||||
obj: 0
|
||||
};
|
||||
this.idFactory = {
|
||||
|
@ -6412,9 +6417,8 @@ var Page = function PageClosure() {
|
|||
};
|
||||
}
|
||||
|
||||
Page.prototype = {
|
||||
_getInheritableProperty(key, getArray = false) {
|
||||
let value = (0, _util.getInheritableProperty)({
|
||||
const value = (0, _util.getInheritableProperty)({
|
||||
dict: this.pageDict,
|
||||
key,
|
||||
getArray,
|
||||
|
@ -6430,61 +6434,61 @@ var Page = function PageClosure() {
|
|||
}
|
||||
|
||||
return _primitives.Dict.merge(this.xref, value);
|
||||
},
|
||||
}
|
||||
|
||||
get content() {
|
||||
return this.pageDict.get('Contents');
|
||||
},
|
||||
}
|
||||
|
||||
get resources() {
|
||||
return (0, _util.shadow)(this, 'resources', this._getInheritableProperty('Resources') || _primitives.Dict.empty);
|
||||
},
|
||||
}
|
||||
|
||||
get mediaBox() {
|
||||
var mediaBox = this._getInheritableProperty('MediaBox', true);
|
||||
const mediaBox = this._getInheritableProperty('MediaBox', true);
|
||||
|
||||
if (!Array.isArray(mediaBox) || mediaBox.length !== 4) {
|
||||
return (0, _util.shadow)(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
|
||||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'mediaBox', mediaBox);
|
||||
},
|
||||
}
|
||||
|
||||
get cropBox() {
|
||||
var cropBox = this._getInheritableProperty('CropBox', true);
|
||||
const cropBox = this._getInheritableProperty('CropBox', true);
|
||||
|
||||
if (!Array.isArray(cropBox) || cropBox.length !== 4) {
|
||||
return (0, _util.shadow)(this, 'cropBox', this.mediaBox);
|
||||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'cropBox', cropBox);
|
||||
},
|
||||
}
|
||||
|
||||
get userUnit() {
|
||||
var obj = this.pageDict.get('UserUnit');
|
||||
let obj = this.pageDict.get('UserUnit');
|
||||
|
||||
if (!(0, _util.isNum)(obj) || obj <= 0) {
|
||||
obj = DEFAULT_USER_UNIT;
|
||||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'userUnit', obj);
|
||||
},
|
||||
}
|
||||
|
||||
get view() {
|
||||
var mediaBox = this.mediaBox,
|
||||
const mediaBox = this.mediaBox,
|
||||
cropBox = this.cropBox;
|
||||
|
||||
if (mediaBox === cropBox) {
|
||||
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);
|
||||
},
|
||||
}
|
||||
|
||||
get rotate() {
|
||||
var rotate = this._getInheritableProperty('Rotate') || 0;
|
||||
let rotate = this._getInheritableProperty('Rotate') || 0;
|
||||
|
||||
if (rotate % 90 !== 0) {
|
||||
rotate = 0;
|
||||
|
@ -6495,20 +6499,18 @@ var Page = function PageClosure() {
|
|||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'rotate', rotate);
|
||||
},
|
||||
}
|
||||
|
||||
getContentStream: function Page_getContentStream() {
|
||||
var content = this.content;
|
||||
var stream;
|
||||
getContentStream() {
|
||||
const content = this.content;
|
||||
let stream;
|
||||
|
||||
if (Array.isArray(content)) {
|
||||
var xref = this.xref;
|
||||
var i,
|
||||
n = content.length;
|
||||
var streams = [];
|
||||
const xref = this.xref;
|
||||
const streams = [];
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
streams.push(xref.fetchIfRef(content[i]));
|
||||
for (const stream of content) {
|
||||
streams.push(xref.fetchIfRef(stream));
|
||||
}
|
||||
|
||||
stream = new _stream.StreamsSequenceStream(streams);
|
||||
|
@ -6519,17 +6521,18 @@ var Page = function PageClosure() {
|
|||
}
|
||||
|
||||
return stream;
|
||||
},
|
||||
loadResources: function Page_loadResources(keys) {
|
||||
}
|
||||
|
||||
loadResources(keys) {
|
||||
if (!this.resourcesPromise) {
|
||||
this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getOperatorList({
|
||||
handler,
|
||||
|
@ -6537,9 +6540,9 @@ var Page = function PageClosure() {
|
|||
intent,
|
||||
renderInteractiveForms
|
||||
}) {
|
||||
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
|
||||
var resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
|
||||
var partialEvaluator = new _evaluator.PartialEvaluator({
|
||||
const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
|
||||
const resourcesPromise = this.loadResources(['ExtGState', 'ColorSpace', 'Pattern', 'Shading', 'XObject', 'Font']);
|
||||
const partialEvaluator = new _evaluator.PartialEvaluator({
|
||||
pdfManager: this.pdfManager,
|
||||
xref: this.xref,
|
||||
handler,
|
||||
|
@ -6550,9 +6553,9 @@ var Page = function PageClosure() {
|
|||
options: this.evaluatorOptions,
|
||||
pdfFunctionFactory: this.pdfFunctionFactory
|
||||
});
|
||||
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
var pageListPromise = dataPromises.then(([contentStream]) => {
|
||||
var opList = new _operator_list.OperatorList(intent, handler, this.pageIndex);
|
||||
const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
const pageListPromise = dataPromises.then(([contentStream]) => {
|
||||
const opList = new _operator_list.OperatorList(intent, handler, this.pageIndex);
|
||||
handler.send('StartRenderPage', {
|
||||
transparency: partialEvaluator.hasBlendModes(this.resources),
|
||||
pageIndex: this.pageIndex,
|
||||
|
@ -6573,21 +6576,19 @@ var Page = function PageClosure() {
|
|||
return pageOpList;
|
||||
}
|
||||
|
||||
var i,
|
||||
ii,
|
||||
opListPromises = [];
|
||||
const opListPromises = [];
|
||||
|
||||
for (i = 0, ii = annotations.length; i < ii; i++) {
|
||||
if (isAnnotationRenderable(annotations[i], intent)) {
|
||||
opListPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderInteractiveForms));
|
||||
for (const annotation of annotations) {
|
||||
if (isAnnotationRenderable(annotation, intent)) {
|
||||
opListPromises.push(annotation.getOperatorList(partialEvaluator, task, renderInteractiveForms));
|
||||
}
|
||||
}
|
||||
|
||||
return Promise.all(opListPromises).then(function (opLists) {
|
||||
pageOpList.addOp(_util.OPS.beginAnnotations, []);
|
||||
|
||||
for (i = 0, ii = opLists.length; i < ii; i++) {
|
||||
pageOpList.addOpList(opLists[i]);
|
||||
for (const opList of opLists) {
|
||||
pageOpList.addOpList(opList);
|
||||
}
|
||||
|
||||
pageOpList.addOp(_util.OPS.endAnnotations, []);
|
||||
|
@ -6595,7 +6596,7 @@ var Page = function PageClosure() {
|
|||
return pageOpList;
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
extractTextContent({
|
||||
handler,
|
||||
|
@ -6604,11 +6605,11 @@ var Page = function PageClosure() {
|
|||
sink,
|
||||
combineTextItems
|
||||
}) {
|
||||
var contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
|
||||
var resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
|
||||
var dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
const contentStreamPromise = this.pdfManager.ensure(this, 'getContentStream');
|
||||
const resourcesPromise = this.loadResources(['ExtGState', 'XObject', 'Font']);
|
||||
const dataPromises = Promise.all([contentStreamPromise, resourcesPromise]);
|
||||
return dataPromises.then(([contentStream]) => {
|
||||
var partialEvaluator = new _evaluator.PartialEvaluator({
|
||||
const partialEvaluator = new _evaluator.PartialEvaluator({
|
||||
pdfManager: this.pdfManager,
|
||||
xref: this.xref,
|
||||
handler,
|
||||
|
@ -6628,11 +6629,11 @@ var Page = function PageClosure() {
|
|||
sink
|
||||
});
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getAnnotationsData(intent) {
|
||||
return this._parsedAnnotations.then(function (annotations) {
|
||||
let annotationsData = [];
|
||||
const annotationsData = [];
|
||||
|
||||
for (let i = 0, ii = annotations.length; i < ii; i++) {
|
||||
if (!intent || isAnnotationRenderable(annotations[i], intent)) {
|
||||
|
@ -6642,11 +6643,11 @@ var Page = function PageClosure() {
|
|||
|
||||
return annotationsData;
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
get annotations() {
|
||||
return (0, _util.shadow)(this, 'annotations', this._getInheritableProperty('Annots') || []);
|
||||
},
|
||||
}
|
||||
|
||||
get _parsedAnnotations() {
|
||||
const parsedAnnotations = this.pdfManager.ensure(this, 'annotations').then(() => {
|
||||
|
@ -6669,18 +6670,41 @@ var Page = function PageClosure() {
|
|||
return (0, _util.shadow)(this, '_parsedAnnotations', parsedAnnotations);
|
||||
}
|
||||
|
||||
};
|
||||
return 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() {
|
||||
var FINGERPRINT_FIRST_BYTES = 1024;
|
||||
var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
|
||||
function find(stream, needle, limit, backwards) {
|
||||
const pos = stream.pos;
|
||||
const end = stream.end;
|
||||
|
||||
function PDFDocument(pdfManager, arg) {
|
||||
var stream;
|
||||
if (pos + limit > end) {
|
||||
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)) {
|
||||
stream = arg;
|
||||
|
@ -6691,60 +6715,22 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
}
|
||||
|
||||
if (stream.length <= 0) {
|
||||
throw new Error('PDFDocument: stream must have data');
|
||||
throw new Error('PDFDocument: Stream must have data');
|
||||
}
|
||||
|
||||
this.pdfManager = pdfManager;
|
||||
this.stream = stream;
|
||||
this.xref = new _obj.XRef(stream, pdfManager);
|
||||
let evaluatorOptions = pdfManager.evaluatorOptions;
|
||||
this.pdfFunctionFactory = new _function.PDFFunctionFactory({
|
||||
xref: this.xref,
|
||||
isEvalSupported: evaluatorOptions.isEvalSupported
|
||||
isEvalSupported: pdfManager.evaluatorOptions.isEvalSupported
|
||||
});
|
||||
this._pagePromises = [];
|
||||
}
|
||||
|
||||
function find(stream, needle, limit, backwards) {
|
||||
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) {
|
||||
parse(recoveryMode) {
|
||||
this.setup(recoveryMode);
|
||||
var version = this.catalog.catDict.get('Version');
|
||||
const version = this.catalog.catDict.get('Version');
|
||||
|
||||
if ((0, _primitives.isName)(version)) {
|
||||
this.pdfFormatVersion = version.name;
|
||||
|
@ -6755,7 +6741,7 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
|
||||
if (this.acroForm) {
|
||||
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) {
|
||||
this.acroForm = null;
|
||||
|
@ -6766,10 +6752,10 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
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;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
get linearization() {
|
||||
let linearization = null;
|
||||
|
@ -6785,26 +6771,26 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'linearization', linearization);
|
||||
},
|
||||
}
|
||||
|
||||
get startXRef() {
|
||||
var stream = this.stream;
|
||||
var startXRef = 0;
|
||||
var linearization = this.linearization;
|
||||
const stream = this.stream;
|
||||
let startXRef = 0;
|
||||
|
||||
if (linearization) {
|
||||
if (this.linearization) {
|
||||
stream.reset();
|
||||
|
||||
if (find(stream, 'endobj', 1024)) {
|
||||
startXRef = stream.pos + 6;
|
||||
}
|
||||
} else {
|
||||
var step = 1024;
|
||||
var found = false,
|
||||
const step = 1024;
|
||||
const startXRefLength = 'startxref'.length;
|
||||
let found = false,
|
||||
pos = stream.end;
|
||||
|
||||
while (!found && pos > 0) {
|
||||
pos -= step - 'startxref'.length;
|
||||
pos -= step - startXRefLength;
|
||||
|
||||
if (pos < 0) {
|
||||
pos = 0;
|
||||
|
@ -6816,13 +6802,13 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
|
||||
if (found) {
|
||||
stream.skip(9);
|
||||
var ch;
|
||||
let ch;
|
||||
|
||||
do {
|
||||
ch = stream.getByte();
|
||||
} while ((0, _util.isSpace)(ch));
|
||||
|
||||
var str = '';
|
||||
let str = '';
|
||||
|
||||
while (ch >= 0x20 && ch <= 0x39) {
|
||||
str += String.fromCharCode(ch);
|
||||
|
@ -6838,20 +6824,23 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'startXRef', startXRef);
|
||||
},
|
||||
}
|
||||
|
||||
checkHeader: function PDFDocument_checkHeader() {
|
||||
var stream = this.stream;
|
||||
checkHeader() {
|
||||
const stream = this.stream;
|
||||
stream.reset();
|
||||
|
||||
if (find(stream, '%PDF-', 1024)) {
|
||||
if (!find(stream, '%PDF-', 1024)) {
|
||||
return;
|
||||
}
|
||||
|
||||
stream.moveStart();
|
||||
var MAX_VERSION_LENGTH = 12;
|
||||
var version = '',
|
||||
const MAX_PDF_VERSION_LENGTH = 12;
|
||||
let version = '',
|
||||
ch;
|
||||
|
||||
while ((ch = stream.getByte()) > 0x20) {
|
||||
if (version.length >= MAX_VERSION_LENGTH) {
|
||||
if (version.length >= MAX_PDF_VERSION_LENGTH) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -6861,26 +6850,35 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
if (!this.pdfFormatVersion) {
|
||||
this.pdfFormatVersion = version.substring(5);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
},
|
||||
parseStartXRef: function PDFDocument_parseStartXRef() {
|
||||
var startXRef = this.startXRef;
|
||||
this.xref.setStartXRef(startXRef);
|
||||
},
|
||||
setup: function PDFDocument_setup(recoveryMode) {
|
||||
|
||||
parseStartXRef() {
|
||||
this.xref.setStartXRef(this.startXRef);
|
||||
}
|
||||
|
||||
setup(recoveryMode) {
|
||||
this.xref.parse(recoveryMode);
|
||||
this.catalog = new _obj.Catalog(this.pdfManager, this.xref);
|
||||
},
|
||||
}
|
||||
|
||||
get numPages() {
|
||||
var linearization = this.linearization;
|
||||
var num = linearization ? linearization.numPages : this.catalog.numPages;
|
||||
const linearization = this.linearization;
|
||||
const num = linearization ? linearization.numPages : this.catalog.numPages;
|
||||
return (0, _util.shadow)(this, 'numPages', num);
|
||||
},
|
||||
}
|
||||
|
||||
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 = {
|
||||
PDFFormatVersion: this.pdfFormatVersion,
|
||||
IsLinearized: !!this.linearization,
|
||||
|
@ -6900,7 +6898,7 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
}
|
||||
|
||||
if ((0, _primitives.isDict)(infoDict)) {
|
||||
for (let key of infoDict.getKeys()) {
|
||||
for (const key of infoDict.getKeys()) {
|
||||
const value = infoDict.get(key);
|
||||
|
||||
if (DocumentInfoValidators[key]) {
|
||||
|
@ -6931,13 +6929,11 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
}
|
||||
|
||||
return (0, _util.shadow)(this, 'documentInfo', docInfo);
|
||||
},
|
||||
}
|
||||
|
||||
get fingerprint() {
|
||||
var xref = this.xref,
|
||||
hash,
|
||||
fileID = '';
|
||||
var idArray = xref.trailer.get('ID');
|
||||
let hash;
|
||||
const idArray = this.xref.trailer.get('ID');
|
||||
|
||||
if (Array.isArray(idArray) && idArray[0] && (0, _util.isString)(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
|
||||
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);
|
||||
}
|
||||
|
||||
for (var i = 0, n = hash.length; i < n; i++) {
|
||||
var hex = hash[i].toString(16);
|
||||
fileID += hex.length === 1 ? '0' + hex : hex;
|
||||
let fingerprint = '';
|
||||
|
||||
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) {
|
||||
const {
|
||||
|
@ -6978,7 +6976,7 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
(0, _util.info)(reason);
|
||||
return catalog.getPageDict(pageIndex);
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getPage(pageIndex) {
|
||||
if (this._pagePromises[pageIndex] !== undefined) {
|
||||
|
@ -7002,14 +7000,23 @@ var PDFDocument = function PDFDocumentClosure() {
|
|||
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 PDFDocument;
|
||||
}();
|
||||
|
||||
}
|
||||
|
||||
exports.PDFDocument = PDFDocument;
|
||||
|
||||
|
@ -8503,7 +8510,7 @@ var XRef = function XRefClosure() {
|
|||
if (xrefEntry.uncompressed) {
|
||||
xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
|
||||
} else {
|
||||
xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
|
||||
xrefEntry = this.fetchCompressed(ref, xrefEntry, suppressEncryption);
|
||||
}
|
||||
|
||||
if ((0, _primitives.isDict)(xrefEntry)) {
|
||||
|
@ -8514,12 +8521,13 @@ var XRef = function XRefClosure() {
|
|||
|
||||
return xrefEntry;
|
||||
},
|
||||
fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
|
||||
|
||||
fetchUncompressed(ref, xrefEntry, suppressEncryption = false) {
|
||||
var gen = ref.gen;
|
||||
var num = ref.num;
|
||||
|
||||
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);
|
||||
|
@ -8537,7 +8545,7 @@ var XRef = function XRefClosure() {
|
|||
}
|
||||
|
||||
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') {
|
||||
|
@ -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) {
|
||||
|
@ -8564,7 +8572,8 @@ var XRef = function XRefClosure() {
|
|||
|
||||
return xrefEntry;
|
||||
},
|
||||
fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
|
||||
|
||||
fetchCompressed(ref, xrefEntry, suppressEncryption = false) {
|
||||
var tableOffset = xrefEntry.offset;
|
||||
var stream = this.fetch(new _primitives.Ref(tableOffset, 0));
|
||||
|
||||
|
@ -8619,7 +8628,7 @@ var XRef = function XRefClosure() {
|
|||
xrefEntry = entries[xrefEntry.gen];
|
||||
|
||||
if (xrefEntry === undefined) {
|
||||
throw new _util.FormatError('bad XRef entry for compressed object');
|
||||
throw new _util.XRefEntryException(`Bad (compressed) XRef entry: ${ref}`);
|
||||
}
|
||||
|
||||
return xrefEntry;
|
||||
|
@ -9240,13 +9249,11 @@ var Ref = function RefClosure() {
|
|||
|
||||
Ref.prototype = {
|
||||
toString: function Ref_toString() {
|
||||
var str = this.num + 'R';
|
||||
|
||||
if (this.gen !== 0) {
|
||||
str += this.gen;
|
||||
return `${this.num}R${this.gen}`;
|
||||
}
|
||||
|
||||
return str;
|
||||
return `${this.num}R`;
|
||||
}
|
||||
};
|
||||
return Ref;
|
||||
|
@ -21977,13 +21984,17 @@ class AnnotationBorderStyle {
|
|||
}
|
||||
|
||||
setWidth(width) {
|
||||
if ((0, _primitives.isName)(width)) {
|
||||
width = parseFloat(width.name);
|
||||
}
|
||||
|
||||
if (Number.isInteger(width)) {
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
|
||||
setStyle(style) {
|
||||
if (!style) {
|
||||
if (!(0, _primitives.isName)(style)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@
|
|||
background-color: rgb(0, 100, 0);
|
||||
}
|
||||
|
||||
.textLayer ::-moz-selection { background: rgb(0,0,255); }
|
||||
|
||||
.textLayer ::selection { background: rgb(0,0,255); }
|
||||
|
||||
.textLayer .endOfContent {
|
||||
|
@ -1675,6 +1677,7 @@ html[dir='rtl'] .outlineItemToggler::before {
|
|||
/* TODO: file FF bug to support ::-moz-selection:window-inactive
|
||||
so we can override the opaque grey background when the window is inactive;
|
||||
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); }
|
||||
|
||||
#errorWrapper {
|
||||
|
|
|
@ -20,7 +20,7 @@ origin:
|
|||
|
||||
# Human-readable identifier for this version/release
|
||||
# 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
|
||||
# https://spdx.org/licenses/
|
||||
|
|
Загрузка…
Ссылка в новой задаче