|
@@ -2,7 +2,7 @@
|
|
* @licstart The following is the entire license notice for the
|
|
* @licstart The following is the entire license notice for the
|
|
* Javascript code in this page
|
|
* Javascript code in this page
|
|
*
|
|
*
|
|
- * Copyright 2021 Mozilla Foundation
|
|
|
|
|
|
+ * Copyright 2022 Mozilla Foundation
|
|
*
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -107,7 +107,7 @@ function normalizeBlendMode(value, parsingArray = false) {
|
|
return "source-over";
|
|
return "source-over";
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(0, _primitives.isName)(value)) {
|
|
|
|
|
|
+ if (!(value instanceof _primitives.Name)) {
|
|
if (parsingArray) {
|
|
if (parsingArray) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
@@ -329,7 +329,7 @@ class PartialEvaluator {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(0, _primitives.isStream)(xObject)) {
|
|
|
|
|
|
+ if (!(xObject instanceof _base_stream.BaseStream)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -545,7 +545,7 @@ class PartialEvaluator {
|
|
const w = dict.get("W", "Width");
|
|
const w = dict.get("W", "Width");
|
|
const h = dict.get("H", "Height");
|
|
const h = dict.get("H", "Height");
|
|
|
|
|
|
- if (!(w && (0, _util.isNum)(w)) || !(h && (0, _util.isNum)(h))) {
|
|
|
|
|
|
+ if (!(w && typeof w === "number") || !(h && typeof h === "number")) {
|
|
(0, _util.warn)("Image dimensions are missing, or not numbers.");
|
|
(0, _util.warn)("Image dimensions are missing, or not numbers.");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -925,7 +925,7 @@ class PartialEvaluator {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- if ((0, _primitives.isDict)(value)) {
|
|
|
|
|
|
+ if (value instanceof _primitives.Dict) {
|
|
isSimpleGState = false;
|
|
isSimpleGState = false;
|
|
promise = promise.then(() => {
|
|
promise = promise.then(() => {
|
|
return this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache);
|
|
return this.handleSMask(value, resources, operatorList, task, stateManager, localColorSpaceCache);
|
|
@@ -989,7 +989,7 @@ class PartialEvaluator {
|
|
let fontRef;
|
|
let fontRef;
|
|
|
|
|
|
if (font) {
|
|
if (font) {
|
|
- if (!(0, _primitives.isRef)(font)) {
|
|
|
|
|
|
+ if (!(font instanceof _primitives.Ref)) {
|
|
throw new _util.FormatError('The "font" object should be a reference.');
|
|
throw new _util.FormatError('The "font" object should be a reference.');
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1022,13 +1022,17 @@ class PartialEvaluator {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (this.parsingType3Font && this.type3FontRefs.has(fontRef)) {
|
|
|
|
+ return errorFont();
|
|
|
|
+ }
|
|
|
|
+
|
|
if (this.fontCache.has(fontRef)) {
|
|
if (this.fontCache.has(fontRef)) {
|
|
return this.fontCache.get(fontRef);
|
|
return this.fontCache.get(fontRef);
|
|
}
|
|
}
|
|
|
|
|
|
font = xref.fetchIfRef(fontRef);
|
|
font = xref.fetchIfRef(fontRef);
|
|
|
|
|
|
- if (!(0, _primitives.isDict)(font)) {
|
|
|
|
|
|
+ if (!(font instanceof _primitives.Dict)) {
|
|
return errorFont();
|
|
return errorFont();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1051,14 +1055,14 @@ class PartialEvaluator {
|
|
descriptor,
|
|
descriptor,
|
|
hash
|
|
hash
|
|
} = preEvaluatedFont;
|
|
} = preEvaluatedFont;
|
|
- const fontRefIsRef = (0, _primitives.isRef)(fontRef);
|
|
|
|
|
|
+ const fontRefIsRef = fontRef instanceof _primitives.Ref;
|
|
let fontID;
|
|
let fontID;
|
|
|
|
|
|
if (fontRefIsRef) {
|
|
if (fontRefIsRef) {
|
|
fontID = `f${fontRef.toString()}`;
|
|
fontID = `f${fontRef.toString()}`;
|
|
}
|
|
}
|
|
|
|
|
|
- if (hash && (0, _primitives.isDict)(descriptor)) {
|
|
|
|
|
|
+ if (hash && descriptor instanceof _primitives.Dict) {
|
|
if (!descriptor.fontAliases) {
|
|
if (!descriptor.fontAliases) {
|
|
descriptor.fontAliases = Object.create(null);
|
|
descriptor.fontAliases = Object.create(null);
|
|
}
|
|
}
|
|
@@ -1227,7 +1231,7 @@ class PartialEvaluator {
|
|
const pattern = this.xref.fetchIfRef(rawPattern);
|
|
const pattern = this.xref.fetchIfRef(rawPattern);
|
|
|
|
|
|
if (pattern) {
|
|
if (pattern) {
|
|
- const dict = (0, _primitives.isStream)(pattern) ? pattern.dict : pattern;
|
|
|
|
|
|
+ const dict = pattern instanceof _base_stream.BaseStream ? pattern.dict : pattern;
|
|
const typeNum = dict.get("PatternType");
|
|
const typeNum = dict.get("PatternType");
|
|
|
|
|
|
if (typeNum === PatternType.TILING) {
|
|
if (typeNum === PatternType.TILING) {
|
|
@@ -1264,7 +1268,7 @@ class PartialEvaluator {
|
|
const length = array.length;
|
|
const length = array.length;
|
|
const operator = this.xref.fetchIfRef(array[0]);
|
|
const operator = this.xref.fetchIfRef(array[0]);
|
|
|
|
|
|
- if (length < 2 || !(0, _primitives.isName)(operator)) {
|
|
|
|
|
|
+ if (length < 2 || !(operator instanceof _primitives.Name)) {
|
|
(0, _util.warn)("Invalid visibility expression");
|
|
(0, _util.warn)("Invalid visibility expression");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -1290,7 +1294,7 @@ class PartialEvaluator {
|
|
currentResult.push(nestedResult);
|
|
currentResult.push(nestedResult);
|
|
|
|
|
|
this._parseVisibilityExpression(object, nestingCounter, nestedResult);
|
|
this._parseVisibilityExpression(object, nestingCounter, nestedResult);
|
|
- } else if ((0, _primitives.isRef)(raw)) {
|
|
|
|
|
|
+ } else if (raw instanceof _primitives.Ref) {
|
|
currentResult.push(raw.toString());
|
|
currentResult.push(raw.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1299,10 +1303,10 @@ class PartialEvaluator {
|
|
async parseMarkedContentProps(contentProperties, resources) {
|
|
async parseMarkedContentProps(contentProperties, resources) {
|
|
let optionalContent;
|
|
let optionalContent;
|
|
|
|
|
|
- if ((0, _primitives.isName)(contentProperties)) {
|
|
|
|
|
|
+ if (contentProperties instanceof _primitives.Name) {
|
|
const properties = resources.get("Properties");
|
|
const properties = resources.get("Properties");
|
|
optionalContent = properties.get(contentProperties.name);
|
|
optionalContent = properties.get(contentProperties.name);
|
|
- } else if ((0, _primitives.isDict)(contentProperties)) {
|
|
|
|
|
|
+ } else if (contentProperties instanceof _primitives.Dict) {
|
|
optionalContent = contentProperties;
|
|
optionalContent = contentProperties;
|
|
} else {
|
|
} else {
|
|
throw new _util.FormatError("Optional content properties malformed.");
|
|
throw new _util.FormatError("Optional content properties malformed.");
|
|
@@ -1333,7 +1337,7 @@ class PartialEvaluator {
|
|
|
|
|
|
const optionalContentGroups = optionalContent.get("OCGs");
|
|
const optionalContentGroups = optionalContent.get("OCGs");
|
|
|
|
|
|
- if (Array.isArray(optionalContentGroups) || (0, _primitives.isDict)(optionalContentGroups)) {
|
|
|
|
|
|
+ if (Array.isArray(optionalContentGroups) || optionalContentGroups instanceof _primitives.Dict) {
|
|
const groupIds = [];
|
|
const groupIds = [];
|
|
|
|
|
|
if (Array.isArray(optionalContentGroups)) {
|
|
if (Array.isArray(optionalContentGroups)) {
|
|
@@ -1347,10 +1351,10 @@ class PartialEvaluator {
|
|
return {
|
|
return {
|
|
type: optionalContentType,
|
|
type: optionalContentType,
|
|
ids: groupIds,
|
|
ids: groupIds,
|
|
- policy: (0, _primitives.isName)(optionalContent.get("P")) ? optionalContent.get("P").name : null,
|
|
|
|
|
|
+ policy: optionalContent.get("P") instanceof _primitives.Name ? optionalContent.get("P").name : null,
|
|
expression: null
|
|
expression: null
|
|
};
|
|
};
|
|
- } else if ((0, _primitives.isRef)(optionalContentGroups)) {
|
|
|
|
|
|
+ } else if (optionalContentGroups instanceof _primitives.Ref) {
|
|
return {
|
|
return {
|
|
type: optionalContentType,
|
|
type: optionalContentType,
|
|
id: optionalContentGroups.toString()
|
|
id: optionalContentGroups.toString()
|
|
@@ -1468,13 +1472,13 @@ class PartialEvaluator {
|
|
xobj = xref.fetch(xobj);
|
|
xobj = xref.fetch(xobj);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(0, _primitives.isStream)(xobj)) {
|
|
|
|
|
|
+ if (!(xobj instanceof _base_stream.BaseStream)) {
|
|
throw new _util.FormatError("XObject should be a stream");
|
|
throw new _util.FormatError("XObject should be a stream");
|
|
}
|
|
}
|
|
|
|
|
|
const type = xobj.dict.get("Subtype");
|
|
const type = xobj.dict.get("Subtype");
|
|
|
|
|
|
- if (!(0, _primitives.isName)(type)) {
|
|
|
|
|
|
+ if (!(type instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("XObject should have a Name subtype");
|
|
throw new _util.FormatError("XObject should have a Name subtype");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1582,9 +1586,9 @@ class PartialEvaluator {
|
|
for (i = 0; i < arrLength; ++i) {
|
|
for (i = 0; i < arrLength; ++i) {
|
|
const arrItem = arr[i];
|
|
const arrItem = arr[i];
|
|
|
|
|
|
- if ((0, _util.isString)(arrItem)) {
|
|
|
|
|
|
+ if (typeof arrItem === "string") {
|
|
Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
|
|
Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
|
|
- } else if ((0, _util.isNum)(arrItem)) {
|
|
|
|
|
|
+ } else if (typeof arrItem === "number") {
|
|
combinedGlyphs.push(arrItem);
|
|
combinedGlyphs.push(arrItem);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1834,7 +1838,7 @@ class PartialEvaluator {
|
|
continue;
|
|
continue;
|
|
|
|
|
|
case _util.OPS.beginMarkedContentProps:
|
|
case _util.OPS.beginMarkedContentProps:
|
|
- if (!(0, _primitives.isName)(args[0])) {
|
|
|
|
|
|
+ if (!(args[0] instanceof _primitives.Name)) {
|
|
(0, _util.warn)(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
|
|
(0, _util.warn)(`Expected name for beginMarkedContentProps arg0=${args[0]}`);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -1914,16 +1918,14 @@ class PartialEvaluator {
|
|
task,
|
|
task,
|
|
resources,
|
|
resources,
|
|
stateManager = null,
|
|
stateManager = null,
|
|
- normalizeWhitespace = false,
|
|
|
|
combineTextItems = false,
|
|
combineTextItems = false,
|
|
includeMarkedContent = false,
|
|
includeMarkedContent = false,
|
|
sink,
|
|
sink,
|
|
- seenStyles = new Set()
|
|
|
|
|
|
+ seenStyles = new Set(),
|
|
|
|
+ viewBox
|
|
}) {
|
|
}) {
|
|
resources = resources || _primitives.Dict.empty;
|
|
resources = resources || _primitives.Dict.empty;
|
|
stateManager = stateManager || new StateManager(new TextState());
|
|
stateManager = stateManager || new StateManager(new TextState());
|
|
- const WhitespaceRegexp = /\s/g;
|
|
|
|
- const DiacriticRegExp = new RegExp("^\\p{Mn}$", "u");
|
|
|
|
const NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
|
|
const NormalizedUnicodes = (0, _unicode.getNormalizedUnicodes)();
|
|
const textContent = {
|
|
const textContent = {
|
|
items: [],
|
|
items: [],
|
|
@@ -2042,27 +2044,14 @@ class PartialEvaluator {
|
|
textContentItem.textAdvanceScale = scaleFactor;
|
|
textContentItem.textAdvanceScale = scaleFactor;
|
|
}
|
|
}
|
|
|
|
|
|
- function replaceWhitespace(str) {
|
|
|
|
- const ii = str.length;
|
|
|
|
- let i = 0,
|
|
|
|
- code;
|
|
|
|
-
|
|
|
|
- while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7f) {
|
|
|
|
- i++;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return i < ii ? str.replace(WhitespaceRegexp, " ") : str;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
function runBidiTransform(textChunk) {
|
|
function runBidiTransform(textChunk) {
|
|
const text = textChunk.str.join("");
|
|
const text = textChunk.str.join("");
|
|
const bidiResult = (0, _bidi.bidi)(text, -1, textChunk.vertical);
|
|
const bidiResult = (0, _bidi.bidi)(text, -1, textChunk.vertical);
|
|
- const str = normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str;
|
|
|
|
return {
|
|
return {
|
|
- str,
|
|
|
|
|
|
+ str: bidiResult.str,
|
|
dir: bidiResult.dir,
|
|
dir: bidiResult.dir,
|
|
- width: textChunk.totalWidth,
|
|
|
|
- height: textChunk.totalHeight,
|
|
|
|
|
|
+ width: Math.abs(textChunk.totalWidth),
|
|
|
|
+ height: Math.abs(textChunk.totalHeight),
|
|
transform: textChunk.transform,
|
|
transform: textChunk.transform,
|
|
fontName: textChunk.fontName,
|
|
fontName: textChunk.fontName,
|
|
hasEOL: textChunk.hasEOL
|
|
hasEOL: textChunk.hasEOL
|
|
@@ -2084,75 +2073,93 @@ class PartialEvaluator {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
- function compareWithLastPosition() {
|
|
|
|
- if (!combineTextItems || !textState.font || !textContentItem.prevTransform) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
|
|
+ function applyInverseRotation(x, y, matrix) {
|
|
|
|
+ const scale = Math.hypot(matrix[0], matrix[1]);
|
|
|
|
+ return [(matrix[0] * x + matrix[1] * y) / scale, (matrix[2] * x + matrix[3] * y) / scale];
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ function compareWithLastPosition() {
|
|
const currentTransform = getCurrentTextTransform();
|
|
const currentTransform = getCurrentTextTransform();
|
|
let posX = currentTransform[4];
|
|
let posX = currentTransform[4];
|
|
let posY = currentTransform[5];
|
|
let posY = currentTransform[5];
|
|
|
|
+ const shiftedX = posX - viewBox[0];
|
|
|
|
+ const shiftedY = posY - viewBox[1];
|
|
|
|
+
|
|
|
|
+ if (shiftedX < 0 || shiftedX > viewBox[2] || shiftedY < 0 || shiftedY > viewBox[3]) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!combineTextItems || !textState.font || !textContentItem.prevTransform) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
let lastPosX = textContentItem.prevTransform[4];
|
|
let lastPosX = textContentItem.prevTransform[4];
|
|
let lastPosY = textContentItem.prevTransform[5];
|
|
let lastPosY = textContentItem.prevTransform[5];
|
|
|
|
|
|
if (lastPosX === posX && lastPosY === posY) {
|
|
if (lastPosX === posX && lastPosY === posY) {
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- let rotate = 0;
|
|
|
|
|
|
+ let rotate = -1;
|
|
|
|
|
|
if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) {
|
|
if (currentTransform[0] && currentTransform[1] === 0 && currentTransform[2] === 0) {
|
|
rotate = currentTransform[0] > 0 ? 0 : 180;
|
|
rotate = currentTransform[0] > 0 ? 0 : 180;
|
|
} else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) {
|
|
} else if (currentTransform[1] && currentTransform[0] === 0 && currentTransform[3] === 0) {
|
|
- rotate += currentTransform[1] > 0 ? 90 : 270;
|
|
|
|
|
|
+ rotate = currentTransform[1] > 0 ? 90 : 270;
|
|
}
|
|
}
|
|
|
|
|
|
- if (rotate !== 0) {
|
|
|
|
- switch (rotate) {
|
|
|
|
- case 90:
|
|
|
|
- [posX, posY] = [posY, posX];
|
|
|
|
- [lastPosX, lastPosY] = [lastPosY, lastPosX];
|
|
|
|
- break;
|
|
|
|
|
|
+ switch (rotate) {
|
|
|
|
+ case 0:
|
|
|
|
+ break;
|
|
|
|
|
|
- case 180:
|
|
|
|
- [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY];
|
|
|
|
- break;
|
|
|
|
|
|
+ case 90:
|
|
|
|
+ [posX, posY] = [posY, posX];
|
|
|
|
+ [lastPosX, lastPosY] = [lastPosY, lastPosX];
|
|
|
|
+ break;
|
|
|
|
|
|
- case 270:
|
|
|
|
- [posX, posY] = [-posY, -posX];
|
|
|
|
- [lastPosX, lastPosY] = [-lastPosY, -lastPosX];
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ case 180:
|
|
|
|
+ [posX, posY, lastPosX, lastPosY] = [-posX, -posY, -lastPosX, -lastPosY];
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case 270:
|
|
|
|
+ [posX, posY] = [-posY, -posX];
|
|
|
|
+ [lastPosX, lastPosY] = [-lastPosY, -lastPosX];
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ [posX, posY] = applyInverseRotation(posX, posY, currentTransform);
|
|
|
|
+ [lastPosX, lastPosY] = applyInverseRotation(lastPosX, lastPosY, textContentItem.prevTransform);
|
|
}
|
|
}
|
|
|
|
|
|
if (textState.font.vertical) {
|
|
if (textState.font.vertical) {
|
|
const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale;
|
|
const advanceY = (lastPosY - posY) / textContentItem.textAdvanceScale;
|
|
const advanceX = posX - lastPosX;
|
|
const advanceX = posX - lastPosX;
|
|
|
|
+ const textOrientation = Math.sign(textContentItem.height);
|
|
|
|
|
|
- if (advanceY < textContentItem.negativeSpaceMax) {
|
|
|
|
|
|
+ if (advanceY < textOrientation * textContentItem.negativeSpaceMax) {
|
|
if (Math.abs(advanceX) > 0.5 * textContentItem.width) {
|
|
if (Math.abs(advanceX) > 0.5 * textContentItem.width) {
|
|
appendEOL();
|
|
appendEOL();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
flushTextContentItem();
|
|
flushTextContentItem();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- if (Math.abs(advanceX) > textContentItem.height) {
|
|
|
|
|
|
+ if (Math.abs(advanceX) > textContentItem.width) {
|
|
appendEOL();
|
|
appendEOL();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- if (advanceY <= textContentItem.trackingSpaceMin) {
|
|
|
|
|
|
+ if (advanceY <= textOrientation * textContentItem.trackingSpaceMin) {
|
|
textContentItem.height += advanceY;
|
|
textContentItem.height += advanceY;
|
|
- } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform)) {
|
|
|
|
|
|
+ } else if (!addFakeSpaces(advanceY, textContentItem.prevTransform, textOrientation)) {
|
|
if (textContentItem.str.length === 0) {
|
|
if (textContentItem.str.length === 0) {
|
|
textContent.items.push({
|
|
textContent.items.push({
|
|
str: " ",
|
|
str: " ",
|
|
dir: "ltr",
|
|
dir: "ltr",
|
|
width: 0,
|
|
width: 0,
|
|
- height: advanceY,
|
|
|
|
|
|
+ height: Math.abs(advanceY),
|
|
transform: textContentItem.prevTransform,
|
|
transform: textContentItem.prevTransform,
|
|
fontName: textContentItem.fontName,
|
|
fontName: textContentItem.fontName,
|
|
hasEOL: false
|
|
hasEOL: false
|
|
@@ -2162,35 +2169,36 @@ class PartialEvaluator {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale;
|
|
const advanceX = (posX - lastPosX) / textContentItem.textAdvanceScale;
|
|
const advanceY = posY - lastPosY;
|
|
const advanceY = posY - lastPosY;
|
|
|
|
+ const textOrientation = Math.sign(textContentItem.width);
|
|
|
|
|
|
- if (advanceX < textContentItem.negativeSpaceMax) {
|
|
|
|
|
|
+ if (advanceX < textOrientation * textContentItem.negativeSpaceMax) {
|
|
if (Math.abs(advanceY) > 0.5 * textContentItem.height) {
|
|
if (Math.abs(advanceY) > 0.5 * textContentItem.height) {
|
|
appendEOL();
|
|
appendEOL();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
flushTextContentItem();
|
|
flushTextContentItem();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
if (Math.abs(advanceY) > textContentItem.height) {
|
|
if (Math.abs(advanceY) > textContentItem.height) {
|
|
appendEOL();
|
|
appendEOL();
|
|
- return;
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
- if (advanceX <= textContentItem.trackingSpaceMin) {
|
|
|
|
|
|
+ if (advanceX <= textOrientation * textContentItem.trackingSpaceMin) {
|
|
textContentItem.width += advanceX;
|
|
textContentItem.width += advanceX;
|
|
- } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform)) {
|
|
|
|
|
|
+ } else if (!addFakeSpaces(advanceX, textContentItem.prevTransform, textOrientation)) {
|
|
if (textContentItem.str.length === 0) {
|
|
if (textContentItem.str.length === 0) {
|
|
textContent.items.push({
|
|
textContent.items.push({
|
|
str: " ",
|
|
str: " ",
|
|
dir: "ltr",
|
|
dir: "ltr",
|
|
- width: advanceX,
|
|
|
|
|
|
+ width: Math.abs(advanceX),
|
|
height: 0,
|
|
height: 0,
|
|
transform: textContentItem.prevTransform,
|
|
transform: textContentItem.prevTransform,
|
|
fontName: textContentItem.fontName,
|
|
fontName: textContentItem.fontName,
|
|
@@ -2200,6 +2208,8 @@ class PartialEvaluator {
|
|
textContentItem.width += advanceX;
|
|
textContentItem.width += advanceX;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
function buildTextContentItem({
|
|
function buildTextContentItem({
|
|
@@ -2227,6 +2237,11 @@ class PartialEvaluator {
|
|
|
|
|
|
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
|
for (let i = 0, ii = glyphs.length; i < ii; i++) {
|
|
const glyph = glyphs[i];
|
|
const glyph = glyphs[i];
|
|
|
|
+
|
|
|
|
+ if (glyph.isInvisibleFormatMark) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
let charSpacing = textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
|
|
let charSpacing = textState.charSpacing + (i + 1 === ii ? extraSpacing : 0);
|
|
let glyphWidth = glyph.width;
|
|
let glyphWidth = glyph.width;
|
|
|
|
|
|
@@ -2235,9 +2250,8 @@ class PartialEvaluator {
|
|
}
|
|
}
|
|
|
|
|
|
let scaledDim = glyphWidth * scale;
|
|
let scaledDim = glyphWidth * scale;
|
|
- let glyphUnicode = glyph.unicode;
|
|
|
|
|
|
|
|
- if (glyphUnicode === " " && (i === 0 || i + 1 === ii || glyphs[i - 1].unicode === " " || glyphs[i + 1].unicode === " " || extraSpacing)) {
|
|
|
|
|
|
+ if (glyph.isWhitespace && (i === 0 || i + 1 === ii || glyphs[i - 1].isWhitespace || glyphs[i + 1].isWhitespace || extraSpacing)) {
|
|
if (!font.vertical) {
|
|
if (!font.vertical) {
|
|
charSpacing += scaledDim + textState.wordSpacing;
|
|
charSpacing += scaledDim + textState.wordSpacing;
|
|
textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
|
|
textState.translateTextMatrix(charSpacing * textState.textHScale, 0);
|
|
@@ -2249,10 +2263,13 @@ class PartialEvaluator {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- compareWithLastPosition();
|
|
|
|
|
|
+ if (!compareWithLastPosition()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
const textChunk = ensureTextContentItem();
|
|
const textChunk = ensureTextContentItem();
|
|
|
|
|
|
- if (DiacriticRegExp.test(glyph.unicode)) {
|
|
|
|
|
|
+ if (glyph.isZeroWidthDiacritic) {
|
|
scaledDim = 0;
|
|
scaledDim = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2270,9 +2287,14 @@ class PartialEvaluator {
|
|
textChunk.prevTransform = getCurrentTextTransform();
|
|
textChunk.prevTransform = getCurrentTextTransform();
|
|
}
|
|
}
|
|
|
|
|
|
- glyphUnicode = NormalizedUnicodes[glyphUnicode] || glyphUnicode;
|
|
|
|
- glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
|
|
|
|
- textChunk.str.push(glyphUnicode);
|
|
|
|
|
|
+ if (glyph.isWhitespace) {
|
|
|
|
+ textChunk.str.push(" ");
|
|
|
|
+ } else {
|
|
|
|
+ let glyphUnicode = glyph.unicode;
|
|
|
|
+ glyphUnicode = NormalizedUnicodes[glyphUnicode] || glyphUnicode;
|
|
|
|
+ glyphUnicode = (0, _unicode.reverseIfRtl)(glyphUnicode);
|
|
|
|
+ textChunk.str.push(glyphUnicode);
|
|
|
|
+ }
|
|
|
|
|
|
if (charSpacing) {
|
|
if (charSpacing) {
|
|
if (!font.vertical) {
|
|
if (!font.vertical) {
|
|
@@ -2301,8 +2323,8 @@ class PartialEvaluator {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- function addFakeSpaces(width, transf) {
|
|
|
|
- if (textContentItem.spaceInFlowMin <= width && width <= textContentItem.spaceInFlowMax) {
|
|
|
|
|
|
+ function addFakeSpaces(width, transf, textOrientation) {
|
|
|
|
+ if (textOrientation * textContentItem.spaceInFlowMin <= width && width <= textOrientation * textContentItem.spaceInFlowMax) {
|
|
if (textContentItem.initialized) {
|
|
if (textContentItem.initialized) {
|
|
textContentItem.str.push(" ");
|
|
textContentItem.str.push(" ");
|
|
}
|
|
}
|
|
@@ -2322,8 +2344,8 @@ class PartialEvaluator {
|
|
textContent.items.push({
|
|
textContent.items.push({
|
|
str: " ",
|
|
str: " ",
|
|
dir: "ltr",
|
|
dir: "ltr",
|
|
- width,
|
|
|
|
- height,
|
|
|
|
|
|
+ width: Math.abs(width),
|
|
|
|
+ height: Math.abs(height),
|
|
transform: transf || getCurrentTextTransform(),
|
|
transform: transf || getCurrentTextTransform(),
|
|
fontName,
|
|
fontName,
|
|
hasEOL: false
|
|
hasEOL: false
|
|
@@ -2573,13 +2595,13 @@ class PartialEvaluator {
|
|
xobj = xref.fetch(xobj);
|
|
xobj = xref.fetch(xobj);
|
|
}
|
|
}
|
|
|
|
|
|
- if (!(0, _primitives.isStream)(xobj)) {
|
|
|
|
|
|
+ if (!(xobj instanceof _base_stream.BaseStream)) {
|
|
throw new _util.FormatError("XObject should be a stream");
|
|
throw new _util.FormatError("XObject should be a stream");
|
|
}
|
|
}
|
|
|
|
|
|
const type = xobj.dict.get("Subtype");
|
|
const type = xobj.dict.get("Subtype");
|
|
|
|
|
|
- if (!(0, _primitives.isName)(type)) {
|
|
|
|
|
|
+ if (!(type instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("XObject should have a Name subtype");
|
|
throw new _util.FormatError("XObject should have a Name subtype");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2620,11 +2642,11 @@ class PartialEvaluator {
|
|
task,
|
|
task,
|
|
resources: xobj.dict.get("Resources") || resources,
|
|
resources: xobj.dict.get("Resources") || resources,
|
|
stateManager: xObjStateManager,
|
|
stateManager: xObjStateManager,
|
|
- normalizeWhitespace,
|
|
|
|
combineTextItems,
|
|
combineTextItems,
|
|
includeMarkedContent,
|
|
includeMarkedContent,
|
|
sink: sinkWrapper,
|
|
sink: sinkWrapper,
|
|
- seenStyles
|
|
|
|
|
|
+ seenStyles,
|
|
|
|
+ viewBox
|
|
}).then(function () {
|
|
}).then(function () {
|
|
if (!sinkWrapper.enqueueInvoked) {
|
|
if (!sinkWrapper.enqueueInvoked) {
|
|
emptyXObjectCache.set(name, xobj.dict.objId, true);
|
|
emptyXObjectCache.set(name, xobj.dict.objId, true);
|
|
@@ -2701,7 +2723,7 @@ class PartialEvaluator {
|
|
if (includeMarkedContent) {
|
|
if (includeMarkedContent) {
|
|
textContent.items.push({
|
|
textContent.items.push({
|
|
type: "beginMarkedContent",
|
|
type: "beginMarkedContent",
|
|
- tag: (0, _primitives.isName)(args[0]) ? args[0].name : null
|
|
|
|
|
|
+ tag: args[0] instanceof _primitives.Name ? args[0].name : null
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2712,14 +2734,14 @@ class PartialEvaluator {
|
|
flushTextContentItem();
|
|
flushTextContentItem();
|
|
let mcid = null;
|
|
let mcid = null;
|
|
|
|
|
|
- if ((0, _primitives.isDict)(args[1])) {
|
|
|
|
|
|
+ if (args[1] instanceof _primitives.Dict) {
|
|
mcid = args[1].get("MCID");
|
|
mcid = args[1].get("MCID");
|
|
}
|
|
}
|
|
|
|
|
|
textContent.items.push({
|
|
textContent.items.push({
|
|
type: "beginMarkedContentProps",
|
|
type: "beginMarkedContentProps",
|
|
id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mcid${mcid}` : null,
|
|
id: Number.isInteger(mcid) ? `${self.idFactory.getPageObjId()}_mcid${mcid}` : null,
|
|
- tag: (0, _primitives.isName)(args[0]) ? args[0].name : null
|
|
|
|
|
|
+ tag: args[0] instanceof _primitives.Name ? args[0].name : null
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2774,7 +2796,7 @@ class PartialEvaluator {
|
|
if (properties.composite) {
|
|
if (properties.composite) {
|
|
const cidSystemInfo = dict.get("CIDSystemInfo");
|
|
const cidSystemInfo = dict.get("CIDSystemInfo");
|
|
|
|
|
|
- if ((0, _primitives.isDict)(cidSystemInfo)) {
|
|
|
|
|
|
+ if (cidSystemInfo instanceof _primitives.Dict) {
|
|
properties.cidSystemInfo = {
|
|
properties.cidSystemInfo = {
|
|
registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
|
|
registry: (0, _util.stringToPDFString)(cidSystemInfo.get("Registry")),
|
|
ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
|
|
ordering: (0, _util.stringToPDFString)(cidSystemInfo.get("Ordering")),
|
|
@@ -2796,9 +2818,9 @@ class PartialEvaluator {
|
|
if (dict.has("Encoding")) {
|
|
if (dict.has("Encoding")) {
|
|
encoding = dict.get("Encoding");
|
|
encoding = dict.get("Encoding");
|
|
|
|
|
|
- if ((0, _primitives.isDict)(encoding)) {
|
|
|
|
|
|
+ if (encoding instanceof _primitives.Dict) {
|
|
baseEncodingName = encoding.get("BaseEncoding");
|
|
baseEncodingName = encoding.get("BaseEncoding");
|
|
- baseEncodingName = (0, _primitives.isName)(baseEncodingName) ? baseEncodingName.name : null;
|
|
|
|
|
|
+ baseEncodingName = baseEncodingName instanceof _primitives.Name ? baseEncodingName.name : null;
|
|
|
|
|
|
if (encoding.has("Differences")) {
|
|
if (encoding.has("Differences")) {
|
|
const diffEncoding = encoding.get("Differences");
|
|
const diffEncoding = encoding.get("Differences");
|
|
@@ -2807,16 +2829,16 @@ class PartialEvaluator {
|
|
for (let j = 0, jj = diffEncoding.length; j < jj; j++) {
|
|
for (let j = 0, jj = diffEncoding.length; j < jj; j++) {
|
|
const data = xref.fetchIfRef(diffEncoding[j]);
|
|
const data = xref.fetchIfRef(diffEncoding[j]);
|
|
|
|
|
|
- if ((0, _util.isNum)(data)) {
|
|
|
|
|
|
+ if (typeof data === "number") {
|
|
index = data;
|
|
index = data;
|
|
- } else if ((0, _primitives.isName)(data)) {
|
|
|
|
|
|
+ } else if (data instanceof _primitives.Name) {
|
|
differences[index++] = data.name;
|
|
differences[index++] = data.name;
|
|
} else {
|
|
} else {
|
|
throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
|
|
throw new _util.FormatError(`Invalid entry in 'Differences' array: ${data}`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } else if ((0, _primitives.isName)(encoding)) {
|
|
|
|
|
|
+ } else if (encoding instanceof _primitives.Name) {
|
|
baseEncodingName = encoding.name;
|
|
baseEncodingName = encoding.name;
|
|
} else {
|
|
} else {
|
|
throw new _util.FormatError("Encoding is not a Name nor a Dict");
|
|
throw new _util.FormatError("Encoding is not a Name nor a Dict");
|
|
@@ -3014,7 +3036,7 @@ class PartialEvaluator {
|
|
return Promise.resolve(null);
|
|
return Promise.resolve(null);
|
|
}
|
|
}
|
|
|
|
|
|
- if ((0, _primitives.isName)(cmapObj)) {
|
|
|
|
|
|
+ if (cmapObj instanceof _primitives.Name) {
|
|
return _cmap.CMapFactory.create({
|
|
return _cmap.CMapFactory.create({
|
|
encoding: cmapObj,
|
|
encoding: cmapObj,
|
|
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
|
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
|
@@ -3026,7 +3048,7 @@ class PartialEvaluator {
|
|
|
|
|
|
return new _to_unicode_map.ToUnicodeMap(cmap.getMap());
|
|
return new _to_unicode_map.ToUnicodeMap(cmap.getMap());
|
|
});
|
|
});
|
|
- } else if ((0, _primitives.isStream)(cmapObj)) {
|
|
|
|
|
|
+ } else if (cmapObj instanceof _base_stream.BaseStream) {
|
|
return _cmap.CMapFactory.create({
|
|
return _cmap.CMapFactory.create({
|
|
encoding: cmapObj,
|
|
encoding: cmapObj,
|
|
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
|
fetchBuiltInCMap: this._fetchBuiltInCMapBound,
|
|
@@ -3168,7 +3190,7 @@ class PartialEvaluator {
|
|
} else {
|
|
} else {
|
|
const baseFontName = dict.get("BaseFont");
|
|
const baseFontName = dict.get("BaseFont");
|
|
|
|
|
|
- if ((0, _primitives.isName)(baseFontName)) {
|
|
|
|
|
|
+ if (baseFontName instanceof _primitives.Name) {
|
|
const metrics = this.getBaseFontMetrics(baseFontName.name);
|
|
const metrics = this.getBaseFontMetrics(baseFontName.name);
|
|
glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
|
|
glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
|
|
defaultWidth = metrics.defaultWidth;
|
|
defaultWidth = metrics.defaultWidth;
|
|
@@ -3230,7 +3252,7 @@ class PartialEvaluator {
|
|
|
|
|
|
const glyphWidths = Metrics[lookupName];
|
|
const glyphWidths = Metrics[lookupName];
|
|
|
|
|
|
- if ((0, _util.isNum)(glyphWidths)) {
|
|
|
|
|
|
+ if (typeof glyphWidths === "number") {
|
|
defaultWidth = glyphWidths;
|
|
defaultWidth = glyphWidths;
|
|
monospace = true;
|
|
monospace = true;
|
|
} else {
|
|
} else {
|
|
@@ -3268,7 +3290,7 @@ class PartialEvaluator {
|
|
const baseDict = dict;
|
|
const baseDict = dict;
|
|
let type = dict.get("Subtype");
|
|
let type = dict.get("Subtype");
|
|
|
|
|
|
- if (!(0, _primitives.isName)(type)) {
|
|
|
|
|
|
+ if (!(type instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("invalid font Subtype");
|
|
throw new _util.FormatError("invalid font Subtype");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3290,7 +3312,7 @@ class PartialEvaluator {
|
|
|
|
|
|
type = dict.get("Subtype");
|
|
type = dict.get("Subtype");
|
|
|
|
|
|
- if (!(0, _primitives.isName)(type)) {
|
|
|
|
|
|
+ if (!(type instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("invalid font Subtype");
|
|
throw new _util.FormatError("invalid font Subtype");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3305,15 +3327,15 @@ class PartialEvaluator {
|
|
hash = new _murmurhash.MurmurHash3_64();
|
|
hash = new _murmurhash.MurmurHash3_64();
|
|
const encoding = baseDict.getRaw("Encoding");
|
|
const encoding = baseDict.getRaw("Encoding");
|
|
|
|
|
|
- if ((0, _primitives.isName)(encoding)) {
|
|
|
|
|
|
+ if (encoding instanceof _primitives.Name) {
|
|
hash.update(encoding.name);
|
|
hash.update(encoding.name);
|
|
- } else if ((0, _primitives.isRef)(encoding)) {
|
|
|
|
|
|
+ } else if (encoding instanceof _primitives.Ref) {
|
|
hash.update(encoding.toString());
|
|
hash.update(encoding.toString());
|
|
- } else if ((0, _primitives.isDict)(encoding)) {
|
|
|
|
|
|
+ } else if (encoding instanceof _primitives.Dict) {
|
|
for (const entry of encoding.getRawValues()) {
|
|
for (const entry of encoding.getRawValues()) {
|
|
- if ((0, _primitives.isName)(entry)) {
|
|
|
|
|
|
+ if (entry instanceof _primitives.Name) {
|
|
hash.update(entry.name);
|
|
hash.update(entry.name);
|
|
- } else if ((0, _primitives.isRef)(entry)) {
|
|
|
|
|
|
+ } else if (entry instanceof _primitives.Ref) {
|
|
hash.update(entry.toString());
|
|
hash.update(entry.toString());
|
|
} else if (Array.isArray(entry)) {
|
|
} else if (Array.isArray(entry)) {
|
|
const diffLength = entry.length,
|
|
const diffLength = entry.length,
|
|
@@ -3322,9 +3344,9 @@ class PartialEvaluator {
|
|
for (let j = 0; j < diffLength; j++) {
|
|
for (let j = 0; j < diffLength; j++) {
|
|
const diffEntry = entry[j];
|
|
const diffEntry = entry[j];
|
|
|
|
|
|
- if ((0, _primitives.isName)(diffEntry)) {
|
|
|
|
|
|
+ if (diffEntry instanceof _primitives.Name) {
|
|
diffBuf[j] = diffEntry.name;
|
|
diffBuf[j] = diffEntry.name;
|
|
- } else if ((0, _util.isNum)(diffEntry) || (0, _primitives.isRef)(diffEntry)) {
|
|
|
|
|
|
+ } else if (typeof diffEntry === "number" || diffEntry instanceof _primitives.Ref) {
|
|
diffBuf[j] = diffEntry.toString();
|
|
diffBuf[j] = diffEntry.toString();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3337,11 +3359,11 @@ class PartialEvaluator {
|
|
hash.update(`${firstChar}-${lastChar}`);
|
|
hash.update(`${firstChar}-${lastChar}`);
|
|
toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
|
toUnicode = dict.get("ToUnicode") || baseDict.get("ToUnicode");
|
|
|
|
|
|
- if ((0, _primitives.isStream)(toUnicode)) {
|
|
|
|
|
|
+ if (toUnicode instanceof _base_stream.BaseStream) {
|
|
const stream = toUnicode.str || toUnicode;
|
|
const stream = toUnicode.str || toUnicode;
|
|
const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
|
|
const uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
|
|
hash.update(uint8array);
|
|
hash.update(uint8array);
|
|
- } else if ((0, _primitives.isName)(toUnicode)) {
|
|
|
|
|
|
+ } else if (toUnicode instanceof _primitives.Name) {
|
|
hash.update(toUnicode.name);
|
|
hash.update(toUnicode.name);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3351,7 +3373,7 @@ class PartialEvaluator {
|
|
const widthsBuf = [];
|
|
const widthsBuf = [];
|
|
|
|
|
|
for (const entry of widths) {
|
|
for (const entry of widths) {
|
|
- if ((0, _util.isNum)(entry) || (0, _primitives.isRef)(entry)) {
|
|
|
|
|
|
+ if (typeof entry === "number" || entry instanceof _primitives.Ref) {
|
|
widthsBuf.push(entry.toString());
|
|
widthsBuf.push(entry.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3367,13 +3389,13 @@ class PartialEvaluator {
|
|
const widthsBuf = [];
|
|
const widthsBuf = [];
|
|
|
|
|
|
for (const entry of compositeWidths) {
|
|
for (const entry of compositeWidths) {
|
|
- if ((0, _util.isNum)(entry) || (0, _primitives.isRef)(entry)) {
|
|
|
|
|
|
+ if (typeof entry === "number" || entry instanceof _primitives.Ref) {
|
|
widthsBuf.push(entry.toString());
|
|
widthsBuf.push(entry.toString());
|
|
} else if (Array.isArray(entry)) {
|
|
} else if (Array.isArray(entry)) {
|
|
const subWidthsBuf = [];
|
|
const subWidthsBuf = [];
|
|
|
|
|
|
for (const element of entry) {
|
|
for (const element of entry) {
|
|
- if ((0, _util.isNum)(element) || (0, _primitives.isRef)(element)) {
|
|
|
|
|
|
+ if (typeof element === "number" || element instanceof _primitives.Ref) {
|
|
subWidthsBuf.push(element.toString());
|
|
subWidthsBuf.push(element.toString());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -3432,7 +3454,7 @@ class PartialEvaluator {
|
|
} else {
|
|
} else {
|
|
let baseFontName = dict.get("BaseFont");
|
|
let baseFontName = dict.get("BaseFont");
|
|
|
|
|
|
- if (!(0, _primitives.isName)(baseFontName)) {
|
|
|
|
|
|
+ if (!(baseFontName instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("Base font is not specified");
|
|
throw new _util.FormatError("Base font is not specified");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3488,11 +3510,11 @@ class PartialEvaluator {
|
|
let fontName = descriptor.get("FontName");
|
|
let fontName = descriptor.get("FontName");
|
|
let baseFont = dict.get("BaseFont");
|
|
let baseFont = dict.get("BaseFont");
|
|
|
|
|
|
- if ((0, _util.isString)(fontName)) {
|
|
|
|
|
|
+ if (typeof fontName === "string") {
|
|
fontName = _primitives.Name.get(fontName);
|
|
fontName = _primitives.Name.get(fontName);
|
|
}
|
|
}
|
|
|
|
|
|
- if ((0, _util.isString)(baseFont)) {
|
|
|
|
|
|
+ if (typeof baseFont === "string") {
|
|
baseFont = _primitives.Name.get(baseFont);
|
|
baseFont = _primitives.Name.get(baseFont);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3511,7 +3533,7 @@ class PartialEvaluator {
|
|
|
|
|
|
fontName = fontName || baseFont;
|
|
fontName = fontName || baseFont;
|
|
|
|
|
|
- if (!(0, _primitives.isName)(fontName)) {
|
|
|
|
|
|
+ if (!(fontName instanceof _primitives.Name)) {
|
|
throw new _util.FormatError("invalid font name");
|
|
throw new _util.FormatError("invalid font name");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3598,7 +3620,7 @@ class PartialEvaluator {
|
|
if (composite) {
|
|
if (composite) {
|
|
const cidEncoding = baseDict.get("Encoding");
|
|
const cidEncoding = baseDict.get("Encoding");
|
|
|
|
|
|
- if ((0, _primitives.isName)(cidEncoding)) {
|
|
|
|
|
|
+ if (cidEncoding instanceof _primitives.Name) {
|
|
properties.cidEncoding = cidEncoding.name;
|
|
properties.cidEncoding = cidEncoding.name;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -3710,6 +3732,13 @@ class TranslatedFont {
|
|
ignoreErrors: false
|
|
ignoreErrors: false
|
|
});
|
|
});
|
|
type3Evaluator.parsingType3Font = true;
|
|
type3Evaluator.parsingType3Font = true;
|
|
|
|
+ const type3FontRefs = new _primitives.RefSet(evaluator.type3FontRefs);
|
|
|
|
+
|
|
|
|
+ if (this.dict.objId && !type3FontRefs.has(this.dict.objId)) {
|
|
|
|
+ type3FontRefs.put(this.dict.objId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ type3Evaluator.type3FontRefs = type3FontRefs;
|
|
const translatedFont = this.font,
|
|
const translatedFont = this.font,
|
|
type3Dependencies = this.type3Dependencies;
|
|
type3Dependencies = this.type3Dependencies;
|
|
let loadCharProcsPromise = Promise.resolve();
|
|
let loadCharProcsPromise = Promise.resolve();
|
|
@@ -4314,7 +4343,7 @@ class EvaluatorPreprocessor {
|
|
}
|
|
}
|
|
|
|
|
|
static get MAX_INVALID_PATH_OPS() {
|
|
static get MAX_INVALID_PATH_OPS() {
|
|
- return (0, _util.shadow)(this, "MAX_INVALID_PATH_OPS", 20);
|
|
|
|
|
|
+ return (0, _util.shadow)(this, "MAX_INVALID_PATH_OPS", 10);
|
|
}
|
|
}
|
|
|
|
|
|
constructor(stream, xref, stateManager = new StateManager()) {
|
|
constructor(stream, xref, stateManager = new StateManager()) {
|