@chialab/pdfjs-lib 1.0.0-alpha.46 → 1.0.0-alpha.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.js +53 -9
- package/dist/browser/worker.js +56 -4
- package/dist/lib/ColorSpace.d.ts +6 -0
- package/dist/lib/SvgCanvasContext.d.ts +3 -0
- package/dist/lib/TextLayer.d.ts +3 -0
- package/dist/node/index.js +53 -9
- package/dist/node/worker.js +56 -4
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -27977,6 +27977,7 @@ var SvgCanvasContext = class {
|
|
|
27977
27977
|
__publicField(this, "_ctx", null);
|
|
27978
27978
|
__publicField(this, "_currentStyle", {
|
|
27979
27979
|
strokeStyle: "#000000",
|
|
27980
|
+
colorSpace: null,
|
|
27980
27981
|
fillStyle: "#000000",
|
|
27981
27982
|
fillRule: "nonzero",
|
|
27982
27983
|
filter: "none",
|
|
@@ -28645,6 +28646,9 @@ var SvgCanvasContext = class {
|
|
|
28645
28646
|
}
|
|
28646
28647
|
this._currentMarked = this._markedStack.pop() ?? null;
|
|
28647
28648
|
}
|
|
28649
|
+
setColorSpace(colorSpaceInfo) {
|
|
28650
|
+
this._currentStyle.colorSpace = colorSpaceInfo ?? null;
|
|
28651
|
+
}
|
|
28648
28652
|
_ensureTransformationGroup() {
|
|
28649
28653
|
const group = {
|
|
28650
28654
|
tag: "g",
|
|
@@ -28870,6 +28874,11 @@ var SvgCanvasContext = class {
|
|
|
28870
28874
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|
|
28871
28875
|
}
|
|
28872
28876
|
}
|
|
28877
|
+
const colorSpace = this._currentStyle.colorSpace;
|
|
28878
|
+
if (colorSpace) {
|
|
28879
|
+
currentElement.attrs["color-space-name"] = colorSpace.name;
|
|
28880
|
+
currentElement.attrs["color-space-type"] = colorSpace.type;
|
|
28881
|
+
}
|
|
28873
28882
|
}
|
|
28874
28883
|
_addPathCommand(command) {
|
|
28875
28884
|
if (!this._currentElement || !isSvgPath(this._currentElement)) {
|
|
@@ -29346,17 +29355,22 @@ var renderTextLayer = (root, options = {}) => {
|
|
|
29346
29355
|
return contents;
|
|
29347
29356
|
}
|
|
29348
29357
|
const tag2 = isHeading ? "span" : node.fontWeight >= 700 ? "strong" : node.fontStyle === "italic" ? "em" : "span";
|
|
29349
|
-
const
|
|
29350
|
-
|
|
29351
|
-
|
|
29352
|
-
|
|
29353
|
-
)
|
|
29358
|
+
const attrs2 = {};
|
|
29359
|
+
if (classes) {
|
|
29360
|
+
attrs2.class = "tl-text";
|
|
29361
|
+
}
|
|
29362
|
+
if (node.colorSpace) {
|
|
29363
|
+
attrs2["data-color-space-type"] = node.colorSpace.type;
|
|
29364
|
+
attrs2["data-color-space-name"] = node.colorSpace.name;
|
|
29365
|
+
}
|
|
29366
|
+
const serializedAttrs2 = serializeAttributes(attrs2);
|
|
29354
29367
|
const serializedStyle = styles ? serializeStyles({
|
|
29355
29368
|
"--tl-left": `${node.left}px`,
|
|
29356
29369
|
"--tl-top": `${node.top}px`,
|
|
29357
29370
|
"--tl-font-size": `${node.fontSize}px`,
|
|
29358
29371
|
"--tl-font-style": node.fontStyle,
|
|
29359
29372
|
"--tl-font-weight": node.fontWeight,
|
|
29373
|
+
"--tl-font-color": node.color,
|
|
29360
29374
|
"--tl-transform": typeof node.angle === "number" && node.angle !== 0 ? `rotate(${node.angle}deg)` : "none"
|
|
29361
29375
|
}) : "";
|
|
29362
29376
|
return `<${tag2}${serializedAttrs2 ? ` ${serializedAttrs2}` : ""}${serializedStyle ? ` style="${serializedStyle}"` : ""}>${contents}</${tag2}>`;
|
|
@@ -29707,6 +29721,8 @@ async function createTextLayer(page, {
|
|
|
29707
29721
|
let leading = 0;
|
|
29708
29722
|
let textRise = 0;
|
|
29709
29723
|
let textPosition = 0;
|
|
29724
|
+
let fillColor;
|
|
29725
|
+
let fillColorSpace;
|
|
29710
29726
|
const createTextItem = (fontFamily2) => {
|
|
29711
29727
|
const font = page.commonObjs.get(fontFamily2);
|
|
29712
29728
|
const riseMatrix = [1, 0, 0, 1, 0, textRise];
|
|
@@ -29822,7 +29838,9 @@ async function createTextLayer(page, {
|
|
|
29822
29838
|
fontSize: fontSize2,
|
|
29823
29839
|
fontWeight: font?.black ? 900 : font?.bold ? 700 : 400,
|
|
29824
29840
|
fontStyle: font?.italic ? "italic" : "normal",
|
|
29825
|
-
angle: angle * (180 / Math.PI)
|
|
29841
|
+
angle: angle * (180 / Math.PI),
|
|
29842
|
+
color: fillColor,
|
|
29843
|
+
colorSpace: fillColorSpace
|
|
29826
29844
|
};
|
|
29827
29845
|
markedContent.children.push(lastTextLayer);
|
|
29828
29846
|
resetTextItem();
|
|
@@ -30087,6 +30105,8 @@ async function createTextLayer(page, {
|
|
|
30087
30105
|
hScale = state.hScale;
|
|
30088
30106
|
leading = state.leading;
|
|
30089
30107
|
textRise = state.textRise;
|
|
30108
|
+
fillColor = state.fillColor;
|
|
30109
|
+
fillColorSpace = state.fillColorSpace;
|
|
30090
30110
|
}
|
|
30091
30111
|
break;
|
|
30092
30112
|
}
|
|
@@ -30101,8 +30121,16 @@ async function createTextLayer(page, {
|
|
|
30101
30121
|
wordSpacing,
|
|
30102
30122
|
hScale,
|
|
30103
30123
|
leading,
|
|
30104
|
-
textRise
|
|
30124
|
+
textRise,
|
|
30125
|
+
fillColor,
|
|
30126
|
+
fillColorSpace
|
|
30105
30127
|
});
|
|
30128
|
+
break;
|
|
30129
|
+
}
|
|
30130
|
+
case OPS.setFillRGBColor: {
|
|
30131
|
+
fillColor = args[0];
|
|
30132
|
+
fillColorSpace = args[1] ?? void 0;
|
|
30133
|
+
break;
|
|
30106
30134
|
}
|
|
30107
30135
|
}
|
|
30108
30136
|
}
|
|
@@ -30198,7 +30226,9 @@ var {
|
|
|
30198
30226
|
endText,
|
|
30199
30227
|
beginMarkedContent,
|
|
30200
30228
|
beginMarkedContentProps,
|
|
30201
|
-
endMarkedContent
|
|
30229
|
+
endMarkedContent,
|
|
30230
|
+
setFillRGBColor,
|
|
30231
|
+
setStrokeRGBColor
|
|
30202
30232
|
} = CanvasGraphics.prototype;
|
|
30203
30233
|
CanvasGraphics.prototype.beginDrawing = function(options) {
|
|
30204
30234
|
if (this.ctx instanceof SvgCanvasContext) {
|
|
@@ -30236,12 +30266,26 @@ CanvasGraphics.prototype.endMarkedContent = function(opIdx) {
|
|
|
30236
30266
|
}
|
|
30237
30267
|
endMarkedContent.call(this, opIdx);
|
|
30238
30268
|
};
|
|
30269
|
+
CanvasGraphics.prototype.setFillRGBColor = function(opIdx, color, colorSpaceInfo) {
|
|
30270
|
+
if (this.ctx instanceof SvgCanvasContext) {
|
|
30271
|
+
this.ctx.setColorSpace(colorSpaceInfo);
|
|
30272
|
+
}
|
|
30273
|
+
setFillRGBColor.call(this, opIdx, color);
|
|
30274
|
+
};
|
|
30275
|
+
CanvasGraphics.prototype.setStrokeRGBColor = function(opIdx, color, colorSpaceInfo) {
|
|
30276
|
+
if (this.ctx instanceof SvgCanvasContext) {
|
|
30277
|
+
this.ctx.setColorSpace(colorSpaceInfo);
|
|
30278
|
+
}
|
|
30279
|
+
setStrokeRGBColor.call(this, opIdx, color);
|
|
30280
|
+
};
|
|
30239
30281
|
Object.assign(CanvasGraphics.prototype, {
|
|
30240
30282
|
[OPS.beginText]: CanvasGraphics.prototype.beginText,
|
|
30241
30283
|
[OPS.endText]: CanvasGraphics.prototype.endText,
|
|
30242
30284
|
[OPS.beginMarkedContent]: CanvasGraphics.prototype.beginMarkedContent,
|
|
30243
30285
|
[OPS.beginMarkedContentProps]: CanvasGraphics.prototype.beginMarkedContentProps,
|
|
30244
|
-
[OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent
|
|
30286
|
+
[OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent,
|
|
30287
|
+
[OPS.setFillRGBColor]: CanvasGraphics.prototype.setFillRGBColor,
|
|
30288
|
+
[OPS.setStrokeRGBColor]: CanvasGraphics.prototype.setStrokeRGBColor
|
|
30245
30289
|
});
|
|
30246
30290
|
|
|
30247
30291
|
// src/index.ts
|
package/dist/browser/worker.js
CHANGED
|
@@ -24067,7 +24067,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24067
24067
|
let x = 0, y = 0;
|
|
24068
24068
|
let stems = 0;
|
|
24069
24069
|
let firstPoint = null;
|
|
24070
|
-
function
|
|
24070
|
+
function parse2(code) {
|
|
24071
24071
|
let i = 0;
|
|
24072
24072
|
while (i < code.length) {
|
|
24073
24073
|
let stackClean = false;
|
|
@@ -24149,7 +24149,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24149
24149
|
subrCode = font.subrs[n + font.subrsBias];
|
|
24150
24150
|
}
|
|
24151
24151
|
if (subrCode) {
|
|
24152
|
-
|
|
24152
|
+
parse2(subrCode);
|
|
24153
24153
|
}
|
|
24154
24154
|
break;
|
|
24155
24155
|
case 11:
|
|
@@ -24348,7 +24348,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24348
24348
|
n = stack.pop() + font.gsubrsBias;
|
|
24349
24349
|
subrCode = font.gsubrs[n];
|
|
24350
24350
|
if (subrCode) {
|
|
24351
|
-
|
|
24351
|
+
parse2(subrCode);
|
|
24352
24352
|
}
|
|
24353
24353
|
break;
|
|
24354
24354
|
case 30:
|
|
@@ -24416,7 +24416,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24416
24416
|
}
|
|
24417
24417
|
}
|
|
24418
24418
|
}
|
|
24419
|
-
|
|
24419
|
+
parse2(charStringCode);
|
|
24420
24420
|
}
|
|
24421
24421
|
var NOOP = "";
|
|
24422
24422
|
var Commands = class {
|
|
@@ -77537,6 +77537,41 @@ AnnotationFactory.saveNewAnnotations = async (evaluator, task, annotations, imag
|
|
|
77537
77537
|
return data;
|
|
77538
77538
|
};
|
|
77539
77539
|
|
|
77540
|
+
// src/lib/ColorSpace.ts
|
|
77541
|
+
var colorSpacesInfo = /* @__PURE__ */ new Map();
|
|
77542
|
+
var parse = ColorSpaceUtils.parse;
|
|
77543
|
+
ColorSpaceUtils.parse = function(args) {
|
|
77544
|
+
const { cs, resources } = args;
|
|
77545
|
+
const result = parse.call(this, args);
|
|
77546
|
+
if (!resources) {
|
|
77547
|
+
return result;
|
|
77548
|
+
}
|
|
77549
|
+
const colorSpaces = resources.get("ColorSpace");
|
|
77550
|
+
if (!(colorSpaces instanceof Dict) || !(cs instanceof Name)) {
|
|
77551
|
+
return result;
|
|
77552
|
+
}
|
|
77553
|
+
const entry = colorSpaces.get(cs.name);
|
|
77554
|
+
if (!entry) {
|
|
77555
|
+
return result;
|
|
77556
|
+
}
|
|
77557
|
+
const type = entry[0] instanceof Name ? entry[0].name : null;
|
|
77558
|
+
const name = entry[1] instanceof Name ? entry[1].name : null;
|
|
77559
|
+
if (!type || !name) {
|
|
77560
|
+
return result;
|
|
77561
|
+
}
|
|
77562
|
+
if (result instanceof ColorSpace) {
|
|
77563
|
+
colorSpacesInfo.set(result, { type, name });
|
|
77564
|
+
return result;
|
|
77565
|
+
}
|
|
77566
|
+
return result.then((result2) => {
|
|
77567
|
+
colorSpacesInfo.set(result2, { type, name });
|
|
77568
|
+
return result2;
|
|
77569
|
+
});
|
|
77570
|
+
};
|
|
77571
|
+
var getColorSpaceInfo = (cs) => {
|
|
77572
|
+
return colorSpacesInfo.get(cs) || null;
|
|
77573
|
+
};
|
|
77574
|
+
|
|
77540
77575
|
// src/lib/Evaluator.ts
|
|
77541
77576
|
var collectMarkedContentLanguage = (stream, xref) => {
|
|
77542
77577
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -77577,8 +77612,22 @@ var collectMarkedContentLanguage = (stream, xref) => {
|
|
|
77577
77612
|
stream.pos = pos;
|
|
77578
77613
|
return map;
|
|
77579
77614
|
};
|
|
77615
|
+
var getColorSpace = PartialEvaluator.prototype._getColorSpace;
|
|
77616
|
+
PartialEvaluator.prototype._getColorSpace = function(...args) {
|
|
77617
|
+
const self2 = this;
|
|
77618
|
+
const result = getColorSpace.apply(this, args);
|
|
77619
|
+
if (result instanceof ColorSpace) {
|
|
77620
|
+
self2._currentColorSpace = result;
|
|
77621
|
+
return result;
|
|
77622
|
+
}
|
|
77623
|
+
return result.then((cs) => {
|
|
77624
|
+
self2._currentColorSpace = cs;
|
|
77625
|
+
return cs;
|
|
77626
|
+
});
|
|
77627
|
+
};
|
|
77580
77628
|
var getOperatorList = PartialEvaluator.prototype.getOperatorList;
|
|
77581
77629
|
PartialEvaluator.prototype.getOperatorList = async function(options, ...args) {
|
|
77630
|
+
const self2 = this;
|
|
77582
77631
|
const { stream, operatorList } = options;
|
|
77583
77632
|
const languages = collectMarkedContentLanguage(stream, this.xref);
|
|
77584
77633
|
const addOp = operatorList.addOp;
|
|
@@ -77594,6 +77643,9 @@ PartialEvaluator.prototype.getOperatorList = async function(options, ...args) {
|
|
|
77594
77643
|
}
|
|
77595
77644
|
}
|
|
77596
77645
|
}
|
|
77646
|
+
if ((fn === OPS.setFillRGBColor || fn === OPS.setStrokeRGBColor) && self2._currentColorSpace) {
|
|
77647
|
+
args2.push(getColorSpaceInfo(self2._currentColorSpace));
|
|
77648
|
+
}
|
|
77597
77649
|
return addOp.call(this, fn, args2);
|
|
77598
77650
|
};
|
|
77599
77651
|
await getOperatorList.call(this, options, ...args);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { ColorSpaceInfo } from './ColorSpace';
|
|
1
2
|
import { Path2D } from './Path2D';
|
|
2
3
|
import { type SvgElement, type SvgNode, type SvgRoot } from './Svg';
|
|
3
4
|
interface CanvasStyle {
|
|
4
5
|
strokeStyle: string | SvgLinearGradient | SvgPattern;
|
|
6
|
+
colorSpace: ColorSpaceInfo | null;
|
|
5
7
|
fillStyle: string | SvgLinearGradient | SvgRadialGradient | SvgPattern;
|
|
6
8
|
fillRule: CanvasFillRule;
|
|
7
9
|
filter: string;
|
|
@@ -141,6 +143,7 @@ export declare class SvgCanvasContext {
|
|
|
141
143
|
id: number;
|
|
142
144
|
} | null): void;
|
|
143
145
|
endMarkedContent(): void;
|
|
146
|
+
setColorSpace(colorSpaceInfo?: ColorSpaceInfo | null): void;
|
|
144
147
|
protected _ensureTransformationGroup(): SvgElement;
|
|
145
148
|
protected _addNode(node: SvgNode, parent?: SvgElement): void;
|
|
146
149
|
protected _applyStyleState(styleState: CanvasStyle): void;
|
package/dist/lib/TextLayer.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Font } from '../pdf.js/src/core/fonts';
|
|
2
2
|
import type { PDFPageProxy, StructTreeContent } from '../pdf.js/src/display/api';
|
|
3
3
|
import { type AnnotationData } from './AnnotationData';
|
|
4
|
+
import type { ColorSpaceInfo } from './ColorSpace';
|
|
4
5
|
import type { StructTreeNodeWithAttrs } from './StructTreePage';
|
|
5
6
|
import { type SvgRoot } from './Svg';
|
|
6
7
|
export interface TextLayerNode {
|
|
@@ -39,6 +40,8 @@ export interface TextLayerText extends TextLayerNode {
|
|
|
39
40
|
fontFallback: string;
|
|
40
41
|
scale?: number;
|
|
41
42
|
angle?: number;
|
|
43
|
+
color?: string;
|
|
44
|
+
colorSpace?: ColorSpaceInfo;
|
|
42
45
|
}
|
|
43
46
|
export interface TextLayerFigure extends TextLayerNode {
|
|
44
47
|
role: 'figure';
|
package/dist/node/index.js
CHANGED
|
@@ -26578,6 +26578,7 @@ var SvgCanvasContext = class {
|
|
|
26578
26578
|
__publicField(this, "_ctx", null);
|
|
26579
26579
|
__publicField(this, "_currentStyle", {
|
|
26580
26580
|
strokeStyle: "#000000",
|
|
26581
|
+
colorSpace: null,
|
|
26581
26582
|
fillStyle: "#000000",
|
|
26582
26583
|
fillRule: "nonzero",
|
|
26583
26584
|
filter: "none",
|
|
@@ -27246,6 +27247,9 @@ var SvgCanvasContext = class {
|
|
|
27246
27247
|
}
|
|
27247
27248
|
this._currentMarked = this._markedStack.pop() ?? null;
|
|
27248
27249
|
}
|
|
27250
|
+
setColorSpace(colorSpaceInfo) {
|
|
27251
|
+
this._currentStyle.colorSpace = colorSpaceInfo ?? null;
|
|
27252
|
+
}
|
|
27249
27253
|
_ensureTransformationGroup() {
|
|
27250
27254
|
const group = {
|
|
27251
27255
|
tag: "g",
|
|
@@ -27471,6 +27475,11 @@ var SvgCanvasContext = class {
|
|
|
27471
27475
|
currentElement.attrs["stroke-dasharray"] = `${this._currentStyle.lineDash.map((entry) => `${entry * Math.max(scale.x, scale.y)}`).join(",")}`;
|
|
27472
27476
|
}
|
|
27473
27477
|
}
|
|
27478
|
+
const colorSpace = this._currentStyle.colorSpace;
|
|
27479
|
+
if (colorSpace) {
|
|
27480
|
+
currentElement.attrs["color-space-name"] = colorSpace.name;
|
|
27481
|
+
currentElement.attrs["color-space-type"] = colorSpace.type;
|
|
27482
|
+
}
|
|
27474
27483
|
}
|
|
27475
27484
|
_addPathCommand(command) {
|
|
27476
27485
|
if (!this._currentElement || !isSvgPath(this._currentElement)) {
|
|
@@ -27947,17 +27956,22 @@ var renderTextLayer = (root, options = {}) => {
|
|
|
27947
27956
|
return contents;
|
|
27948
27957
|
}
|
|
27949
27958
|
const tag2 = isHeading ? "span" : node.fontWeight >= 700 ? "strong" : node.fontStyle === "italic" ? "em" : "span";
|
|
27950
|
-
const
|
|
27951
|
-
|
|
27952
|
-
|
|
27953
|
-
|
|
27954
|
-
)
|
|
27959
|
+
const attrs2 = {};
|
|
27960
|
+
if (classes) {
|
|
27961
|
+
attrs2.class = "tl-text";
|
|
27962
|
+
}
|
|
27963
|
+
if (node.colorSpace) {
|
|
27964
|
+
attrs2["data-color-space-type"] = node.colorSpace.type;
|
|
27965
|
+
attrs2["data-color-space-name"] = node.colorSpace.name;
|
|
27966
|
+
}
|
|
27967
|
+
const serializedAttrs2 = serializeAttributes(attrs2);
|
|
27955
27968
|
const serializedStyle = styles ? serializeStyles({
|
|
27956
27969
|
"--tl-left": `${node.left}px`,
|
|
27957
27970
|
"--tl-top": `${node.top}px`,
|
|
27958
27971
|
"--tl-font-size": `${node.fontSize}px`,
|
|
27959
27972
|
"--tl-font-style": node.fontStyle,
|
|
27960
27973
|
"--tl-font-weight": node.fontWeight,
|
|
27974
|
+
"--tl-font-color": node.color,
|
|
27961
27975
|
"--tl-transform": typeof node.angle === "number" && node.angle !== 0 ? `rotate(${node.angle}deg)` : "none"
|
|
27962
27976
|
}) : "";
|
|
27963
27977
|
return `<${tag2}${serializedAttrs2 ? ` ${serializedAttrs2}` : ""}${serializedStyle ? ` style="${serializedStyle}"` : ""}>${contents}</${tag2}>`;
|
|
@@ -28308,6 +28322,8 @@ async function createTextLayer(page, {
|
|
|
28308
28322
|
let leading = 0;
|
|
28309
28323
|
let textRise = 0;
|
|
28310
28324
|
let textPosition = 0;
|
|
28325
|
+
let fillColor;
|
|
28326
|
+
let fillColorSpace;
|
|
28311
28327
|
const createTextItem = (fontFamily2) => {
|
|
28312
28328
|
const font = page.commonObjs.get(fontFamily2);
|
|
28313
28329
|
const riseMatrix = [1, 0, 0, 1, 0, textRise];
|
|
@@ -28423,7 +28439,9 @@ async function createTextLayer(page, {
|
|
|
28423
28439
|
fontSize: fontSize2,
|
|
28424
28440
|
fontWeight: font?.black ? 900 : font?.bold ? 700 : 400,
|
|
28425
28441
|
fontStyle: font?.italic ? "italic" : "normal",
|
|
28426
|
-
angle: angle * (180 / Math.PI)
|
|
28442
|
+
angle: angle * (180 / Math.PI),
|
|
28443
|
+
color: fillColor,
|
|
28444
|
+
colorSpace: fillColorSpace
|
|
28427
28445
|
};
|
|
28428
28446
|
markedContent.children.push(lastTextLayer);
|
|
28429
28447
|
resetTextItem();
|
|
@@ -28688,6 +28706,8 @@ async function createTextLayer(page, {
|
|
|
28688
28706
|
hScale = state.hScale;
|
|
28689
28707
|
leading = state.leading;
|
|
28690
28708
|
textRise = state.textRise;
|
|
28709
|
+
fillColor = state.fillColor;
|
|
28710
|
+
fillColorSpace = state.fillColorSpace;
|
|
28691
28711
|
}
|
|
28692
28712
|
break;
|
|
28693
28713
|
}
|
|
@@ -28702,8 +28722,16 @@ async function createTextLayer(page, {
|
|
|
28702
28722
|
wordSpacing,
|
|
28703
28723
|
hScale,
|
|
28704
28724
|
leading,
|
|
28705
|
-
textRise
|
|
28725
|
+
textRise,
|
|
28726
|
+
fillColor,
|
|
28727
|
+
fillColorSpace
|
|
28706
28728
|
});
|
|
28729
|
+
break;
|
|
28730
|
+
}
|
|
28731
|
+
case OPS.setFillRGBColor: {
|
|
28732
|
+
fillColor = args[0];
|
|
28733
|
+
fillColorSpace = args[1] ?? void 0;
|
|
28734
|
+
break;
|
|
28707
28735
|
}
|
|
28708
28736
|
}
|
|
28709
28737
|
}
|
|
@@ -28799,7 +28827,9 @@ var {
|
|
|
28799
28827
|
endText,
|
|
28800
28828
|
beginMarkedContent,
|
|
28801
28829
|
beginMarkedContentProps,
|
|
28802
|
-
endMarkedContent
|
|
28830
|
+
endMarkedContent,
|
|
28831
|
+
setFillRGBColor,
|
|
28832
|
+
setStrokeRGBColor
|
|
28803
28833
|
} = CanvasGraphics.prototype;
|
|
28804
28834
|
CanvasGraphics.prototype.beginDrawing = function(options) {
|
|
28805
28835
|
if (this.ctx instanceof SvgCanvasContext) {
|
|
@@ -28837,12 +28867,26 @@ CanvasGraphics.prototype.endMarkedContent = function(opIdx) {
|
|
|
28837
28867
|
}
|
|
28838
28868
|
endMarkedContent.call(this, opIdx);
|
|
28839
28869
|
};
|
|
28870
|
+
CanvasGraphics.prototype.setFillRGBColor = function(opIdx, color, colorSpaceInfo) {
|
|
28871
|
+
if (this.ctx instanceof SvgCanvasContext) {
|
|
28872
|
+
this.ctx.setColorSpace(colorSpaceInfo);
|
|
28873
|
+
}
|
|
28874
|
+
setFillRGBColor.call(this, opIdx, color);
|
|
28875
|
+
};
|
|
28876
|
+
CanvasGraphics.prototype.setStrokeRGBColor = function(opIdx, color, colorSpaceInfo) {
|
|
28877
|
+
if (this.ctx instanceof SvgCanvasContext) {
|
|
28878
|
+
this.ctx.setColorSpace(colorSpaceInfo);
|
|
28879
|
+
}
|
|
28880
|
+
setStrokeRGBColor.call(this, opIdx, color);
|
|
28881
|
+
};
|
|
28840
28882
|
Object.assign(CanvasGraphics.prototype, {
|
|
28841
28883
|
[OPS.beginText]: CanvasGraphics.prototype.beginText,
|
|
28842
28884
|
[OPS.endText]: CanvasGraphics.prototype.endText,
|
|
28843
28885
|
[OPS.beginMarkedContent]: CanvasGraphics.prototype.beginMarkedContent,
|
|
28844
28886
|
[OPS.beginMarkedContentProps]: CanvasGraphics.prototype.beginMarkedContentProps,
|
|
28845
|
-
[OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent
|
|
28887
|
+
[OPS.endMarkedContent]: CanvasGraphics.prototype.endMarkedContent,
|
|
28888
|
+
[OPS.setFillRGBColor]: CanvasGraphics.prototype.setFillRGBColor,
|
|
28889
|
+
[OPS.setStrokeRGBColor]: CanvasGraphics.prototype.setStrokeRGBColor
|
|
28846
28890
|
});
|
|
28847
28891
|
|
|
28848
28892
|
// src/index.ts
|
package/dist/node/worker.js
CHANGED
|
@@ -24069,7 +24069,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24069
24069
|
let x = 0, y = 0;
|
|
24070
24070
|
let stems = 0;
|
|
24071
24071
|
let firstPoint = null;
|
|
24072
|
-
function
|
|
24072
|
+
function parse2(code) {
|
|
24073
24073
|
let i = 0;
|
|
24074
24074
|
while (i < code.length) {
|
|
24075
24075
|
let stackClean = false;
|
|
@@ -24151,7 +24151,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24151
24151
|
subrCode = font.subrs[n + font.subrsBias];
|
|
24152
24152
|
}
|
|
24153
24153
|
if (subrCode) {
|
|
24154
|
-
|
|
24154
|
+
parse2(subrCode);
|
|
24155
24155
|
}
|
|
24156
24156
|
break;
|
|
24157
24157
|
case 11:
|
|
@@ -24350,7 +24350,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24350
24350
|
n = stack.pop() + font.gsubrsBias;
|
|
24351
24351
|
subrCode = font.gsubrs[n];
|
|
24352
24352
|
if (subrCode) {
|
|
24353
|
-
|
|
24353
|
+
parse2(subrCode);
|
|
24354
24354
|
}
|
|
24355
24355
|
break;
|
|
24356
24356
|
case 30:
|
|
@@ -24418,7 +24418,7 @@ function compileCharString(charStringCode, cmds, font, glyphId) {
|
|
|
24418
24418
|
}
|
|
24419
24419
|
}
|
|
24420
24420
|
}
|
|
24421
|
-
|
|
24421
|
+
parse2(charStringCode);
|
|
24422
24422
|
}
|
|
24423
24423
|
var NOOP = "";
|
|
24424
24424
|
var Commands = class {
|
|
@@ -77539,6 +77539,41 @@ AnnotationFactory.saveNewAnnotations = async (evaluator, task, annotations, imag
|
|
|
77539
77539
|
return data;
|
|
77540
77540
|
};
|
|
77541
77541
|
|
|
77542
|
+
// src/lib/ColorSpace.ts
|
|
77543
|
+
var colorSpacesInfo = /* @__PURE__ */ new Map();
|
|
77544
|
+
var parse = ColorSpaceUtils.parse;
|
|
77545
|
+
ColorSpaceUtils.parse = function(args) {
|
|
77546
|
+
const { cs, resources } = args;
|
|
77547
|
+
const result = parse.call(this, args);
|
|
77548
|
+
if (!resources) {
|
|
77549
|
+
return result;
|
|
77550
|
+
}
|
|
77551
|
+
const colorSpaces = resources.get("ColorSpace");
|
|
77552
|
+
if (!(colorSpaces instanceof Dict) || !(cs instanceof Name)) {
|
|
77553
|
+
return result;
|
|
77554
|
+
}
|
|
77555
|
+
const entry = colorSpaces.get(cs.name);
|
|
77556
|
+
if (!entry) {
|
|
77557
|
+
return result;
|
|
77558
|
+
}
|
|
77559
|
+
const type = entry[0] instanceof Name ? entry[0].name : null;
|
|
77560
|
+
const name = entry[1] instanceof Name ? entry[1].name : null;
|
|
77561
|
+
if (!type || !name) {
|
|
77562
|
+
return result;
|
|
77563
|
+
}
|
|
77564
|
+
if (result instanceof ColorSpace) {
|
|
77565
|
+
colorSpacesInfo.set(result, { type, name });
|
|
77566
|
+
return result;
|
|
77567
|
+
}
|
|
77568
|
+
return result.then((result2) => {
|
|
77569
|
+
colorSpacesInfo.set(result2, { type, name });
|
|
77570
|
+
return result2;
|
|
77571
|
+
});
|
|
77572
|
+
};
|
|
77573
|
+
var getColorSpaceInfo = (cs) => {
|
|
77574
|
+
return colorSpacesInfo.get(cs) || null;
|
|
77575
|
+
};
|
|
77576
|
+
|
|
77542
77577
|
// src/lib/Evaluator.ts
|
|
77543
77578
|
var collectMarkedContentLanguage = (stream, xref) => {
|
|
77544
77579
|
const map = /* @__PURE__ */ new Map();
|
|
@@ -77579,8 +77614,22 @@ var collectMarkedContentLanguage = (stream, xref) => {
|
|
|
77579
77614
|
stream.pos = pos;
|
|
77580
77615
|
return map;
|
|
77581
77616
|
};
|
|
77617
|
+
var getColorSpace = PartialEvaluator.prototype._getColorSpace;
|
|
77618
|
+
PartialEvaluator.prototype._getColorSpace = function(...args) {
|
|
77619
|
+
const self2 = this;
|
|
77620
|
+
const result = getColorSpace.apply(this, args);
|
|
77621
|
+
if (result instanceof ColorSpace) {
|
|
77622
|
+
self2._currentColorSpace = result;
|
|
77623
|
+
return result;
|
|
77624
|
+
}
|
|
77625
|
+
return result.then((cs) => {
|
|
77626
|
+
self2._currentColorSpace = cs;
|
|
77627
|
+
return cs;
|
|
77628
|
+
});
|
|
77629
|
+
};
|
|
77582
77630
|
var getOperatorList = PartialEvaluator.prototype.getOperatorList;
|
|
77583
77631
|
PartialEvaluator.prototype.getOperatorList = async function(options, ...args) {
|
|
77632
|
+
const self2 = this;
|
|
77584
77633
|
const { stream, operatorList } = options;
|
|
77585
77634
|
const languages = collectMarkedContentLanguage(stream, this.xref);
|
|
77586
77635
|
const addOp = operatorList.addOp;
|
|
@@ -77596,6 +77645,9 @@ PartialEvaluator.prototype.getOperatorList = async function(options, ...args) {
|
|
|
77596
77645
|
}
|
|
77597
77646
|
}
|
|
77598
77647
|
}
|
|
77648
|
+
if ((fn === OPS.setFillRGBColor || fn === OPS.setStrokeRGBColor) && self2._currentColorSpace) {
|
|
77649
|
+
args2.push(getColorSpaceInfo(self2._currentColorSpace));
|
|
77650
|
+
}
|
|
77599
77651
|
return addOp.call(this, fn, args2);
|
|
77600
77652
|
};
|
|
77601
77653
|
await getOperatorList.call(this, options, ...args);
|
package/package.json
CHANGED