pdf-parser.js 5.2.26 → 5.2.28
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/{afm-widths-BYiX2L9D.cjs → afm-widths-BHD2HZIL.cjs} +553 -642
- package/dist/{afm-widths-blUDDjlI.js → afm-widths-B_IGbGky.js} +553 -642
- package/dist/afm-widths.cjs +1 -1
- package/dist/afm-widths.js +1 -1
- package/dist/annotations.cjs +5 -3
- package/dist/annotations.d.cts +2 -2
- package/dist/annotations.d.ts +2 -2
- package/dist/annotations.js +5 -3
- package/dist/attachments.d.cts +2 -2
- package/dist/attachments.d.ts +2 -2
- package/dist/builtin-encoding.cjs +17 -6
- package/dist/builtin-encoding.js +17 -6
- package/dist/bytes/crc32.cjs +5 -3
- package/dist/bytes/crc32.js +5 -3
- package/dist/bytes/flate.cjs +0 -1
- package/dist/bytes/flate.js +0 -1
- package/dist/cff-bounds.cjs +73 -45
- package/dist/cff-bounds.js +73 -45
- package/dist/cff.cjs +13 -6
- package/dist/cff.js +13 -6
- package/dist/cmap-table.cjs +54 -26
- package/dist/cmap-table.js +54 -26
- package/dist/cmap.cjs +5 -3
- package/dist/cmap.js +5 -3
- package/dist/content-read.d.cts +1 -1
- package/dist/content-read.d.ts +1 -1
- package/dist/content-write.cjs +21 -14
- package/dist/content-write.d.cts +2 -2
- package/dist/content-write.d.ts +2 -2
- package/dist/content-write.js +21 -14
- package/dist/crypto/aes.cjs +76 -55
- package/dist/crypto/aes.js +76 -55
- package/dist/crypto/md5.cjs +345 -149
- package/dist/crypto/md5.js +345 -149
- package/dist/crypto/rc4.cjs +5 -4
- package/dist/crypto/rc4.js +5 -4
- package/dist/crypto/sha2.cjs +92 -43
- package/dist/crypto/sha2.js +92 -43
- package/dist/document.cjs +17 -11
- package/dist/document.d.cts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/document.js +17 -11
- package/dist/{embedded-font-Bnhh4juV.d.ts → embedded-font-ByD7ZiQS.d.ts} +1 -1
- package/dist/{embedded-font-CEf-zBCA.d.cts → embedded-font-DgVBedw6.d.cts} +1 -1
- package/dist/embedded-font-write.d.cts +2 -2
- package/dist/embedded-font-write.d.ts +2 -2
- package/dist/embedded-font.cjs +4 -2
- package/dist/embedded-font.d.cts +1 -1
- package/dist/embedded-font.d.ts +1 -1
- package/dist/embedded-font.js +4 -2
- package/dist/encoding.cjs +1 -1
- package/dist/encoding.js +1 -1
- package/dist/encrypt-write.cjs +25 -21
- package/dist/encrypt-write.d.cts +1 -1
- package/dist/encrypt-write.d.ts +1 -1
- package/dist/encrypt-write.js +25 -21
- package/dist/encrypt.cjs +43 -64
- package/dist/encrypt.d.cts +1 -1
- package/dist/encrypt.d.ts +1 -1
- package/dist/encrypt.js +43 -64
- package/dist/filters.cjs +46 -26
- package/dist/filters.d.cts +1 -1
- package/dist/filters.d.ts +1 -1
- package/dist/filters.js +46 -26
- package/dist/font-face.cjs +2 -1
- package/dist/font-face.js +2 -1
- package/dist/font-read.cjs +12 -6
- package/dist/font-read.d.cts +1 -1
- package/dist/font-read.d.ts +1 -1
- package/dist/font-read.js +12 -6
- package/dist/font-registry.d.cts +3 -3
- package/dist/font-registry.d.ts +3 -3
- package/dist/font-tables.cjs +55 -28
- package/dist/font-tables.js +55 -28
- package/dist/form.cjs +13 -8
- package/dist/form.d.cts +2 -2
- package/dist/form.d.ts +2 -2
- package/dist/form.js +13 -8
- package/dist/gdef-table.cjs +6 -3
- package/dist/gdef-table.js +6 -3
- package/dist/{glyf-contours-C0epBNqP.d.ts → glyf-contours-B1PsI9oA.d.ts} +1 -1
- package/dist/{glyf-contours-BRpvd0rt.d.cts → glyf-contours-NHBpgks-.d.cts} +1 -1
- package/dist/glyf-contours.cjs +3 -1
- package/dist/glyf-contours.d.cts +1 -1
- package/dist/glyf-contours.d.ts +1 -1
- package/dist/glyf-contours.js +3 -1
- package/dist/glyf.cjs +22 -11
- package/dist/glyf.js +22 -11
- package/dist/gpos-table.cjs +37 -19
- package/dist/gpos-table.js +37 -19
- package/dist/gsub-table.cjs +40 -25
- package/dist/gsub-table.js +40 -25
- package/dist/hmtx-table.cjs +5 -3
- package/dist/hmtx-table.js +5 -3
- package/dist/image/ccitt-encode.cjs +8 -5
- package/dist/image/ccitt-encode.js +8 -5
- package/dist/image/ccitt.cjs +801 -209
- package/dist/image/ccitt.js +801 -209
- package/dist/image/jbig2-arith.cjs +340 -306
- package/dist/image/jbig2-arith.js +340 -306
- package/dist/image/jbig2-bitmap.cjs +8 -5
- package/dist/image/jbig2-bitmap.js +8 -5
- package/dist/image/jbig2-generic.cjs +240 -69
- package/dist/image/jbig2-generic.js +240 -69
- package/dist/image/jbig2-text.cjs +4 -2
- package/dist/image/jbig2-text.js +4 -2
- package/dist/image/jbig2.cjs +69 -31
- package/dist/image/jbig2.js +69 -31
- package/dist/image/jp2-boxes.cjs +52 -27
- package/dist/image/jp2-boxes.js +52 -27
- package/dist/image/jpeg-info.cjs +29 -24
- package/dist/image/jpeg-info.js +29 -24
- package/dist/image/jpeg2000-codestream.cjs +61 -32
- package/dist/image/jpeg2000-codestream.js +61 -32
- package/dist/image/jpeg2000-dwt.cjs +2 -1
- package/dist/image/jpeg2000-dwt.js +2 -1
- package/dist/image/jpeg2000-t1.cjs +21 -11
- package/dist/image/jpeg2000-t1.js +21 -11
- package/dist/image/jpeg2000-t2.cjs +12 -5
- package/dist/image/jpeg2000-t2.js +12 -5
- package/dist/image/jpeg2000-tagtree.cjs +8 -4
- package/dist/image/jpeg2000-tagtree.js +8 -4
- package/dist/image/jpeg2000.cjs +11 -6
- package/dist/image/jpeg2000.js +11 -6
- package/dist/image/png-decode.cjs +62 -39
- package/dist/image/png-decode.d.cts +3 -2
- package/dist/image/png-decode.d.ts +3 -2
- package/dist/image/png-decode.js +62 -39
- package/dist/image/png-filter.cjs +23 -15
- package/dist/image/png-filter.js +23 -15
- package/dist/images-read.cjs +41 -36
- package/dist/images-read.d.cts +2 -2
- package/dist/images-read.d.ts +2 -2
- package/dist/images-read.js +41 -36
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interpret.cjs +68 -40
- package/dist/interpret.d.cts +1 -1
- package/dist/interpret.d.ts +1 -1
- package/dist/interpret.js +68 -40
- package/dist/lexer.cjs +86 -51
- package/dist/lexer.js +86 -51
- package/dist/math-content-write.cjs +9 -5
- package/dist/math-content-write.js +9 -5
- package/dist/math-font-write.cjs +2 -1
- package/dist/math-font-write.d.cts +1 -1
- package/dist/math-font-write.d.ts +1 -1
- package/dist/math-font-write.js +2 -1
- package/dist/math-font.cjs +16 -7
- package/dist/math-font.js +16 -7
- package/dist/math-table.cjs +25 -13
- package/dist/math-table.js +25 -13
- package/dist/matrix.cjs +3 -2
- package/dist/matrix.js +3 -2
- package/dist/measure.cjs +1 -1
- package/dist/measure.js +1 -1
- package/dist/names.cjs +7 -7
- package/dist/names.d.cts +2 -2
- package/dist/names.d.ts +2 -2
- package/dist/names.js +7 -7
- package/dist/navigation.cjs +16 -12
- package/dist/navigation.d.cts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.js +16 -12
- package/dist/{objects-B7HdMeWS.d.cts → objects-e2RS3-yT.d.cts} +3 -3
- package/dist/{objects-B7HdMeWS.d.ts → objects-e2RS3-yT.d.ts} +3 -3
- package/dist/objects.d.cts +1 -1
- package/dist/objects.d.ts +1 -1
- package/dist/optional-content.d.cts +2 -2
- package/dist/optional-content.d.ts +2 -2
- package/dist/ot-layout-common.cjs +22 -15
- package/dist/ot-layout-common.js +22 -15
- package/dist/parse.cjs +7 -5
- package/dist/parse.d.cts +1 -1
- package/dist/parse.d.ts +1 -1
- package/dist/parse.js +7 -5
- package/dist/pdf-text.cjs +5 -2
- package/dist/pdf-text.js +5 -2
- package/dist/predictors.cjs +14 -9
- package/dist/predictors.d.cts +1 -1
- package/dist/predictors.d.ts +1 -1
- package/dist/predictors.js +14 -9
- package/dist/raster.cjs +30 -19
- package/dist/raster.d.cts +8 -8
- package/dist/raster.d.ts +8 -8
- package/dist/raster.js +30 -19
- package/dist/read.cjs +29 -16
- package/dist/read.js +29 -16
- package/dist/serialize.cjs +6 -2
- package/dist/serialize.d.cts +1 -1
- package/dist/serialize.d.ts +1 -1
- package/dist/serialize.js +6 -2
- package/dist/sfnt-subset.cjs +25 -13
- package/dist/sfnt-subset.d.cts +1 -1
- package/dist/sfnt-subset.d.ts +1 -1
- package/dist/sfnt-subset.js +25 -13
- package/dist/sfnt.cjs +20 -10
- package/dist/sfnt.js +20 -10
- package/dist/structure.d.cts +2 -2
- package/dist/structure.d.ts +2 -2
- package/dist/text-group.cjs +0 -1
- package/dist/text-group.js +0 -1
- package/dist/text-layout.d.cts +1 -1
- package/dist/text-layout.d.ts +1 -1
- package/dist/tounicode.cjs +4 -2
- package/dist/tounicode.d.cts +1 -1
- package/dist/tounicode.d.ts +1 -1
- package/dist/tounicode.js +4 -2
- package/dist/winansi.cjs +1 -1
- package/dist/winansi.js +1 -1
- package/dist/write.cjs +20 -12
- package/dist/write.d.cts +1 -1
- package/dist/write.d.ts +1 -1
- package/dist/write.js +20 -12
- package/dist/xref.cjs +5 -2
- package/dist/xref.d.cts +1 -1
- package/dist/xref.d.ts +1 -1
- package/dist/xref.js +5 -2
- package/package.json +1 -1
package/dist/images-read.js
CHANGED
|
@@ -3,10 +3,14 @@ import { decodeStream } from "./filters.js";
|
|
|
3
3
|
import { decodeJpeg2000 } from "./image/jpeg2000.js";
|
|
4
4
|
import { PNG_MAX_DIMENSION, PNG_MAX_PIXELS, encodePng, readJpegInfo } from "byte-codec";
|
|
5
5
|
//#region src/images-read.ts
|
|
6
|
+
const CMYK_COMPONENT_COUNT = 4;
|
|
7
|
+
const RGB_CHANNEL_COUNT = 3;
|
|
8
|
+
const MAX_BYTE_VALUE = 255;
|
|
9
|
+
const BITS_PER_BYTE = 8;
|
|
6
10
|
function componentsOf(cs) {
|
|
7
11
|
if (cs.kind === "gray") return 1;
|
|
8
|
-
if (cs.kind === "cmyk") return
|
|
9
|
-
return
|
|
12
|
+
if (cs.kind === "cmyk") return CMYK_COMPONENT_COUNT;
|
|
13
|
+
return RGB_CHANNEL_COUNT;
|
|
10
14
|
}
|
|
11
15
|
function resolveColorSpace(csObj, resolver, sink) {
|
|
12
16
|
const resolved = resolver.resolve(csObj);
|
|
@@ -30,7 +34,7 @@ function resolveColorSpace(csObj, resolver, sink) {
|
|
|
30
34
|
const streamObj = resolver.resolve(arr[1]);
|
|
31
35
|
const n = streamObj?.kind === "stream" ? asNumber(dictGet(streamObj.dict, "N")) : void 0;
|
|
32
36
|
if (n === 1) return { kind: "gray" };
|
|
33
|
-
if (n ===
|
|
37
|
+
if (n === CMYK_COMPONENT_COUNT) return { kind: "cmyk" };
|
|
34
38
|
return { kind: "rgb" };
|
|
35
39
|
}
|
|
36
40
|
if (family === "Indexed") {
|
|
@@ -54,9 +58,9 @@ function resolveColorSpace(csObj, resolver, sink) {
|
|
|
54
58
|
};
|
|
55
59
|
}
|
|
56
60
|
function unpackSamples(data, width, height, componentsPerPixel, bitsPerComponent) {
|
|
57
|
-
if (bitsPerComponent ===
|
|
61
|
+
if (bitsPerComponent === BITS_PER_BYTE) return Array.from(data.subarray(0, width * height * componentsPerPixel));
|
|
58
62
|
const samplesPerRow = width * componentsPerPixel;
|
|
59
|
-
const bytesPerRow = Math.ceil(samplesPerRow * bitsPerComponent /
|
|
63
|
+
const bytesPerRow = Math.ceil(samplesPerRow * bitsPerComponent / BITS_PER_BYTE);
|
|
60
64
|
const out = [];
|
|
61
65
|
for (let row = 0; row < height; row++) {
|
|
62
66
|
const rowStart = row * bytesPerRow;
|
|
@@ -64,8 +68,8 @@ function unpackSamples(data, width, height, componentsPerPixel, bitsPerComponent
|
|
|
64
68
|
for (let s = 0; s < samplesPerRow; s++) {
|
|
65
69
|
let value = 0;
|
|
66
70
|
for (let b = 0; b < bitsPerComponent; b++) {
|
|
67
|
-
const byteIndex = rowStart + Math.floor(bitPos /
|
|
68
|
-
const bitIndex = 7 - bitPos %
|
|
71
|
+
const byteIndex = rowStart + Math.floor(bitPos / BITS_PER_BYTE);
|
|
72
|
+
const bitIndex = 7 - bitPos % BITS_PER_BYTE;
|
|
69
73
|
const bit = (data[byteIndex] ?? 0) >> bitIndex & 1;
|
|
70
74
|
value = value << 1 | bit;
|
|
71
75
|
bitPos++;
|
|
@@ -77,13 +81,13 @@ function unpackSamples(data, width, height, componentsPerPixel, bitsPerComponent
|
|
|
77
81
|
}
|
|
78
82
|
function scaleToByte(value, maxValue, inverted) {
|
|
79
83
|
const v = inverted ? maxValue - value : value;
|
|
80
|
-
return maxValue ===
|
|
84
|
+
return maxValue === MAX_BYTE_VALUE ? v : Math.round(v * MAX_BYTE_VALUE / maxValue);
|
|
81
85
|
}
|
|
82
86
|
function cmykToRgbByte(c, m, y, k) {
|
|
83
87
|
return {
|
|
84
|
-
r: Math.round(
|
|
85
|
-
g: Math.round(
|
|
86
|
-
b: Math.round(
|
|
88
|
+
r: Math.round(MAX_BYTE_VALUE * (1 - c) * (1 - k)),
|
|
89
|
+
g: Math.round(MAX_BYTE_VALUE * (1 - m) * (1 - k)),
|
|
90
|
+
b: Math.round(MAX_BYTE_VALUE * (1 - y) * (1 - k))
|
|
87
91
|
};
|
|
88
92
|
}
|
|
89
93
|
function sampleFromPalette(base, lookup, offset) {
|
|
@@ -95,7 +99,7 @@ function sampleFromPalette(base, lookup, offset) {
|
|
|
95
99
|
b: g
|
|
96
100
|
};
|
|
97
101
|
}
|
|
98
|
-
if (base.kind === "cmyk") return cmykToRgbByte((lookup[offset] ?? 0) /
|
|
102
|
+
if (base.kind === "cmyk") return cmykToRgbByte((lookup[offset] ?? 0) / MAX_BYTE_VALUE, (lookup[offset + 1] ?? 0) / MAX_BYTE_VALUE, (lookup[offset + 2] ?? 0) / MAX_BYTE_VALUE, (lookup[offset + 3] ?? 0) / MAX_BYTE_VALUE);
|
|
99
103
|
return {
|
|
100
104
|
r: lookup[offset] ?? 0,
|
|
101
105
|
g: lookup[offset + 1] ?? 0,
|
|
@@ -107,7 +111,7 @@ function buildRawImage(data, width, height, bitsPerComponent, colorSpace, invert
|
|
|
107
111
|
if (colorSpace.kind === "indexed") {
|
|
108
112
|
const indices = unpackSamples(data, width, height, 1, bitsPerComponent);
|
|
109
113
|
const baseComponents = componentsOf(colorSpace.base);
|
|
110
|
-
const out = new Uint8Array(width * height * (colorSpace.base.kind === "gray" ? 1 :
|
|
114
|
+
const out = new Uint8Array(width * height * (colorSpace.base.kind === "gray" ? 1 : RGB_CHANNEL_COUNT));
|
|
111
115
|
let outIdx = 0;
|
|
112
116
|
for (const index of indices) {
|
|
113
117
|
const rgb = sampleFromPalette(colorSpace.base, colorSpace.lookup, index * baseComponents);
|
|
@@ -121,7 +125,7 @@ function buildRawImage(data, width, height, bitsPerComponent, colorSpace, invert
|
|
|
121
125
|
return {
|
|
122
126
|
width,
|
|
123
127
|
height,
|
|
124
|
-
channels: colorSpace.base.kind === "gray" ? 1 :
|
|
128
|
+
channels: colorSpace.base.kind === "gray" ? 1 : RGB_CHANNEL_COUNT,
|
|
125
129
|
data: out
|
|
126
130
|
};
|
|
127
131
|
}
|
|
@@ -135,26 +139,27 @@ function buildRawImage(data, width, height, bitsPerComponent, colorSpace, invert
|
|
|
135
139
|
};
|
|
136
140
|
}
|
|
137
141
|
if (colorSpace.kind === "rgb") {
|
|
138
|
-
const samples = unpackSamples(data, width, height,
|
|
142
|
+
const samples = unpackSamples(data, width, height, RGB_CHANNEL_COUNT, bitsPerComponent);
|
|
143
|
+
const out = Uint8Array.from(samples, (v) => scaleToByte(v, maxValue, inverted));
|
|
139
144
|
return {
|
|
140
145
|
width,
|
|
141
146
|
height,
|
|
142
|
-
channels:
|
|
143
|
-
data:
|
|
147
|
+
channels: RGB_CHANNEL_COUNT,
|
|
148
|
+
data: out
|
|
144
149
|
};
|
|
145
150
|
}
|
|
146
|
-
const samples = unpackSamples(data, width, height,
|
|
147
|
-
const out = new Uint8Array(width * height *
|
|
151
|
+
const samples = unpackSamples(data, width, height, CMYK_COMPONENT_COUNT, bitsPerComponent);
|
|
152
|
+
const out = new Uint8Array(width * height * RGB_CHANNEL_COUNT);
|
|
148
153
|
for (let px = 0; px < width * height; px++) {
|
|
149
|
-
const rgb = cmykToRgbByte(scaleToByte(samples[px *
|
|
150
|
-
out[px *
|
|
151
|
-
out[px *
|
|
152
|
-
out[px *
|
|
154
|
+
const rgb = cmykToRgbByte(scaleToByte(samples[px * CMYK_COMPONENT_COUNT] ?? 0, maxValue, inverted) / MAX_BYTE_VALUE, scaleToByte(samples[px * CMYK_COMPONENT_COUNT + 1] ?? 0, maxValue, inverted) / MAX_BYTE_VALUE, scaleToByte(samples[px * CMYK_COMPONENT_COUNT + 2] ?? 0, maxValue, inverted) / MAX_BYTE_VALUE, scaleToByte(samples[px * CMYK_COMPONENT_COUNT + 3] ?? 0, maxValue, inverted) / MAX_BYTE_VALUE);
|
|
155
|
+
out[px * RGB_CHANNEL_COUNT] = rgb.r;
|
|
156
|
+
out[px * RGB_CHANNEL_COUNT + 1] = rgb.g;
|
|
157
|
+
out[px * RGB_CHANNEL_COUNT + 2] = rgb.b;
|
|
153
158
|
}
|
|
154
159
|
return {
|
|
155
160
|
width,
|
|
156
161
|
height,
|
|
157
|
-
channels:
|
|
162
|
+
channels: RGB_CHANNEL_COUNT,
|
|
158
163
|
data: out
|
|
159
164
|
};
|
|
160
165
|
}
|
|
@@ -165,8 +170,8 @@ function readSoftMaskAlpha(dict, width, height, resolver, sink) {
|
|
|
165
170
|
if (decoded.remainingFilter !== void 0) return;
|
|
166
171
|
const smaskWidth = asNumber(dictGet(smaskObj.dict, "Width")) ?? width;
|
|
167
172
|
const smaskHeight = asNumber(dictGet(smaskObj.dict, "Height")) ?? height;
|
|
168
|
-
const smaskBpc = asNumber(dictGet(smaskObj.dict, "BitsPerComponent")) ??
|
|
169
|
-
if (smaskWidth !== width || smaskHeight !== height || smaskBpc !==
|
|
173
|
+
const smaskBpc = asNumber(dictGet(smaskObj.dict, "BitsPerComponent")) ?? BITS_PER_BYTE;
|
|
174
|
+
if (smaskWidth !== width || smaskHeight !== height || smaskBpc !== BITS_PER_BYTE) return;
|
|
170
175
|
return decoded.bytes.subarray(0, width * height);
|
|
171
176
|
}
|
|
172
177
|
function jpeg2000ChannelKind(image, dict, resolver, sink) {
|
|
@@ -178,7 +183,7 @@ function jpeg2000ChannelKind(image, dict, resolver, sink) {
|
|
|
178
183
|
if (image.colourSpace === "greyscale") return "gray";
|
|
179
184
|
if (image.colourSpace === "cmyk") return "cmyk";
|
|
180
185
|
if (image.colourSpace === "srgb" || image.colourSpace === "sycc" || image.colourSpace === "e-srgb" || image.colourSpace === "rommrgb") return "rgb";
|
|
181
|
-
return image.components.length >=
|
|
186
|
+
return image.components.length >= CMYK_COMPONENT_COUNT ? "cmyk" : image.components.length >= RGB_CHANNEL_COUNT ? "rgb" : "gray";
|
|
182
187
|
}
|
|
183
188
|
function readJpeg2000Image(dict, raw, resolver, sink) {
|
|
184
189
|
let image;
|
|
@@ -204,7 +209,7 @@ function readJpeg2000Image(dict, raw, resolver, sink) {
|
|
|
204
209
|
return;
|
|
205
210
|
}
|
|
206
211
|
const kind = jpeg2000ChannelKind(image, dict, resolver, sink);
|
|
207
|
-
const required = kind === "cmyk" ?
|
|
212
|
+
const required = kind === "cmyk" ? CMYK_COMPONENT_COUNT : kind === "rgb" ? RGB_CHANNEL_COUNT : 1;
|
|
208
213
|
if (image.components.length < required) {
|
|
209
214
|
sink({
|
|
210
215
|
code: "image/jpx-undecodable",
|
|
@@ -219,15 +224,15 @@ function readJpeg2000Image(dict, raw, resolver, sink) {
|
|
|
219
224
|
message: `JPXDecode image carries ${String(image.components.length)} components where its colour space needs ${String(required)}; the extra channel(s) are ignored`
|
|
220
225
|
});
|
|
221
226
|
const maximum = (1 << image.bitDepth) - 1;
|
|
222
|
-
const scale = (value) => image.bitDepth ===
|
|
227
|
+
const scale = (value) => image.bitDepth === BITS_PER_BYTE ? value : Math.round(value * MAX_BYTE_VALUE / maximum);
|
|
223
228
|
const pixels = image.width * image.height;
|
|
224
|
-
const channels = kind === "gray" ? 1 :
|
|
229
|
+
const channels = kind === "gray" ? 1 : RGB_CHANNEL_COUNT;
|
|
225
230
|
const data = new Uint8Array(pixels * channels);
|
|
226
231
|
if (kind === "cmyk") for (let i = 0; i < pixels; i++) {
|
|
227
|
-
const rgb = cmykToRgbByte(scale(image.components[0]?.[i] ?? 0) /
|
|
228
|
-
data[i *
|
|
229
|
-
data[i *
|
|
230
|
-
data[i *
|
|
232
|
+
const rgb = cmykToRgbByte(scale(image.components[0]?.[i] ?? 0) / MAX_BYTE_VALUE, scale(image.components[1]?.[i] ?? 0) / MAX_BYTE_VALUE, scale(image.components[2]?.[i] ?? 0) / MAX_BYTE_VALUE, scale(image.components[3]?.[i] ?? 0) / MAX_BYTE_VALUE);
|
|
233
|
+
data[i * RGB_CHANNEL_COUNT] = rgb.r;
|
|
234
|
+
data[i * RGB_CHANNEL_COUNT + 1] = rgb.g;
|
|
235
|
+
data[i * RGB_CHANNEL_COUNT + 2] = rgb.b;
|
|
231
236
|
}
|
|
232
237
|
else for (let channel = 0; channel < channels; channel++) {
|
|
233
238
|
const plane = image.components[channel];
|
|
@@ -301,8 +306,8 @@ function readImageXObject(dict, raw, resolver, sink) {
|
|
|
301
306
|
});
|
|
302
307
|
return;
|
|
303
308
|
}
|
|
304
|
-
const bitsPerComponent = asNumber(dictGet(dict, "BitsPerComponent") ?? dictGet(dict, "BPC")) ??
|
|
305
|
-
if (bitsPerComponent !== 1 && bitsPerComponent !== 2 && bitsPerComponent !== 4 && bitsPerComponent !==
|
|
309
|
+
const bitsPerComponent = asNumber(dictGet(dict, "BitsPerComponent") ?? dictGet(dict, "BPC")) ?? BITS_PER_BYTE;
|
|
310
|
+
if (bitsPerComponent !== 1 && bitsPerComponent !== 2 && bitsPerComponent !== 4 && bitsPerComponent !== BITS_PER_BYTE) {
|
|
306
311
|
sink({
|
|
307
312
|
code: "image/unsupported-bit-depth",
|
|
308
313
|
severity: "warning",
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_afm_widths = require("./afm-widths-
|
|
2
|
+
const require_afm_widths = require("./afm-widths-BHD2HZIL.cjs");
|
|
3
3
|
const require_image_ccitt = require("./image/ccitt.cjs");
|
|
4
4
|
const require_image_jbig2_errors = require("./image/jbig2-errors.cjs");
|
|
5
5
|
const require_image_jbig2 = require("./image/jbig2.cjs");
|
package/dist/index.d.cts
CHANGED
|
@@ -3,7 +3,7 @@ import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnost
|
|
|
3
3
|
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.cjs";
|
|
4
4
|
import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
|
|
5
5
|
import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
|
|
6
|
-
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-
|
|
6
|
+
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-DgVBedw6.cjs";
|
|
7
7
|
import { WinAnsiSubstitution } from "./winansi.cjs";
|
|
8
8
|
import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.cjs";
|
|
9
9
|
import { FontFace, FontFaceParseError, readFontFace } from "./font-face.cjs";
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { NOOP_DIAGNOSTIC_SINK, PdfDiagnostic, PdfDiagnosticSeverity, PdfDiagnost
|
|
|
3
3
|
import { LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema } from "./layout.js";
|
|
4
4
|
import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
|
|
5
5
|
import { PdfBytesSchema, pdfCodec } from "./codec.js";
|
|
6
|
-
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-
|
|
6
|
+
import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-ByD7ZiQS.js";
|
|
7
7
|
import { WinAnsiSubstitution } from "./winansi.js";
|
|
8
8
|
import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.js";
|
|
9
9
|
import { FontFace, FontFaceParseError, readFontFace } from "./font-face.js";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as STANDARD_METRICS } from "./afm-widths-
|
|
1
|
+
import { t as STANDARD_METRICS } from "./afm-widths-B_IGbGky.js";
|
|
2
2
|
import { decodeCcittFax } from "./image/ccitt.js";
|
|
3
3
|
import { Jbig2ParseError, Jbig2UnsupportedError } from "./image/jbig2-errors.js";
|
|
4
4
|
import { decodeJbig2Embedded } from "./image/jbig2.js";
|
package/dist/interpret.cjs
CHANGED
|
@@ -8,6 +8,8 @@ let document_schema_js = require("document-schema.js");
|
|
|
8
8
|
//#region src/interpret.ts
|
|
9
9
|
const MAX_FORM_XOBJECT_DEPTH = 12;
|
|
10
10
|
const FALLBACK_GLYPH_WIDTH_PER_1000 = 500;
|
|
11
|
+
const GLYPH_SPACE_PER_TEXT_SPACE_UNIT = 1e3;
|
|
12
|
+
const ASCII_SPACE = 32;
|
|
11
13
|
const DEFAULT_LINE_WIDTH_PT = 1;
|
|
12
14
|
function initialTextParameters() {
|
|
13
15
|
return {
|
|
@@ -72,31 +74,37 @@ function rgbColor(operands) {
|
|
|
72
74
|
b: numAt(operands, 2)
|
|
73
75
|
};
|
|
74
76
|
}
|
|
77
|
+
const CMYK_K_INDEX = 3;
|
|
75
78
|
function cmykColor(operands) {
|
|
76
79
|
const c = numAt(operands, 0);
|
|
77
80
|
const m = numAt(operands, 1);
|
|
78
81
|
const y = numAt(operands, 2);
|
|
79
|
-
const k = numAt(operands,
|
|
82
|
+
const k = numAt(operands, CMYK_K_INDEX);
|
|
80
83
|
return {
|
|
81
84
|
r: (1 - c) * (1 - k),
|
|
82
85
|
g: (1 - m) * (1 - k),
|
|
83
86
|
b: (1 - y) * (1 - k)
|
|
84
87
|
};
|
|
85
88
|
}
|
|
89
|
+
const RGB_COMPONENT_COUNT = 3;
|
|
90
|
+
const CMYK_COMPONENT_COUNT = 4;
|
|
86
91
|
function genericColor(operands) {
|
|
87
92
|
const numericOperands = operands.filter((o) => o.kind === "number");
|
|
88
93
|
if (numericOperands.length === 1) return grayColor(numAt(numericOperands, 0));
|
|
89
|
-
if (numericOperands.length ===
|
|
90
|
-
if (numericOperands.length ===
|
|
94
|
+
if (numericOperands.length === RGB_COMPONENT_COUNT) return rgbColor(numericOperands);
|
|
95
|
+
if (numericOperands.length === CMYK_COMPONENT_COUNT) return cmykColor(numericOperands);
|
|
91
96
|
}
|
|
97
|
+
const MATRIX_D_INDEX = 3;
|
|
98
|
+
const MATRIX_E_INDEX = 4;
|
|
99
|
+
const MATRIX_F_INDEX = 5;
|
|
92
100
|
function matrixFromOperands(operands) {
|
|
93
101
|
return [
|
|
94
102
|
numAt(operands, 0),
|
|
95
103
|
numAt(operands, 1),
|
|
96
104
|
numAt(operands, 2),
|
|
97
|
-
numAt(operands,
|
|
98
|
-
numAt(operands,
|
|
99
|
-
numAt(operands,
|
|
105
|
+
numAt(operands, MATRIX_D_INDEX),
|
|
106
|
+
numAt(operands, MATRIX_E_INDEX),
|
|
107
|
+
numAt(operands, MATRIX_F_INDEX)
|
|
100
108
|
];
|
|
101
109
|
}
|
|
102
110
|
const SHAPE_ABS_TOLERANCE_PT = .001;
|
|
@@ -140,9 +148,10 @@ function closedPolygonCorners(subpath) {
|
|
|
140
148
|
if (nearlyEqualPoints(first, last, shapeTolerance(Math.max(bounds.maxX - bounds.minX, bounds.maxY - bounds.minY)))) corners.pop();
|
|
141
149
|
return corners;
|
|
142
150
|
}
|
|
151
|
+
const RECTANGLE_CORNER_COUNT = 4;
|
|
143
152
|
function detectRect(subpath, paint) {
|
|
144
153
|
const corners = closedPolygonCorners(subpath);
|
|
145
|
-
if (corners?.length !==
|
|
154
|
+
if (corners?.length !== RECTANGLE_CORNER_COUNT) return;
|
|
146
155
|
const { minX, minY, maxX, maxY } = boundsOf(corners);
|
|
147
156
|
const widthPt = maxX - minX;
|
|
148
157
|
const heightPt = maxY - minY;
|
|
@@ -190,9 +199,10 @@ function expectedEllipseControl(atExtreme, atExtremeKind, otherEnd, center, kx,
|
|
|
190
199
|
y: atExtreme.y
|
|
191
200
|
};
|
|
192
201
|
}
|
|
202
|
+
const ELLIPSE_SEGMENT_COUNT = 4;
|
|
193
203
|
function detectEllipse(subpath, paint) {
|
|
194
204
|
const segments = subpath.segments;
|
|
195
|
-
if (!subpath.closed || segments.length !==
|
|
205
|
+
if (!subpath.closed || segments.length !== ELLIPSE_SEGMENT_COUNT || segments.some((segment) => segment.kind !== "cubic")) return;
|
|
196
206
|
const start = {
|
|
197
207
|
x: subpath.startXPt,
|
|
198
208
|
y: subpath.startYPt
|
|
@@ -218,16 +228,16 @@ function detectEllipse(subpath, paint) {
|
|
|
218
228
|
y: finalSegment.yPt
|
|
219
229
|
}, start, Math.max(tolX, tolY))) return;
|
|
220
230
|
const extremes = onCurve.map((point) => cardinalExtremeOf(point, center, rx, ry, tolX, tolY));
|
|
221
|
-
if (extremes.some((extreme) => extreme === void 0) || new Set(extremes).size !==
|
|
231
|
+
if (extremes.some((extreme) => extreme === void 0) || new Set(extremes).size !== ELLIPSE_SEGMENT_COUNT) return;
|
|
222
232
|
const kx = rx * require_matrix.BEZIER_KAPPA;
|
|
223
233
|
const ky = ry * require_matrix.BEZIER_KAPPA;
|
|
224
234
|
const controlTolerance = Math.max(tolX, tolY);
|
|
225
|
-
for (let i = 0; i <
|
|
235
|
+
for (let i = 0; i < ELLIPSE_SEGMENT_COUNT; i += 1) {
|
|
226
236
|
const segment = segments[i];
|
|
227
237
|
const from = onCurve[i];
|
|
228
238
|
const fromKind = extremes[i];
|
|
229
|
-
const to = onCurve[(i + 1) %
|
|
230
|
-
const toKind = extremes[(i + 1) %
|
|
239
|
+
const to = onCurve[(i + 1) % ELLIPSE_SEGMENT_COUNT];
|
|
240
|
+
const toKind = extremes[(i + 1) % ELLIPSE_SEGMENT_COUNT];
|
|
231
241
|
if (segment?.kind !== "cubic" || from === void 0 || to === void 0 || fromKind === void 0 || toKind === void 0) return;
|
|
232
242
|
const expectedC1 = expectedEllipseControl(from, fromKind, to, center, kx, ky);
|
|
233
243
|
const expectedC2 = expectedEllipseControl(to, toKind, from, center, kx, ky);
|
|
@@ -274,17 +284,38 @@ function classifyShape(subpaths, paint, style) {
|
|
|
274
284
|
if (subpaths.length !== 1 || subpath === void 0) return;
|
|
275
285
|
return detectRect(subpath, paint) ?? detectEllipse(subpath, paint) ?? detectLine(subpath, paint, style);
|
|
276
286
|
}
|
|
287
|
+
var MarkedContentStack = class {
|
|
288
|
+
#frames;
|
|
289
|
+
constructor(seed = []) {
|
|
290
|
+
this.#frames = [...seed];
|
|
291
|
+
}
|
|
292
|
+
open(frame) {
|
|
293
|
+
this.#frames.push(frame);
|
|
294
|
+
}
|
|
295
|
+
close() {
|
|
296
|
+
this.#frames.pop();
|
|
297
|
+
}
|
|
298
|
+
inScope(key) {
|
|
299
|
+
for (let i = this.#frames.length - 1; i >= 0; i--) {
|
|
300
|
+
const frame = this.#frames[i];
|
|
301
|
+
if (frame !== void 0 && key in frame) return frame[key];
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const RE_HEIGHT_INDEX = 3;
|
|
306
|
+
const OPERAND_INDEX_3 = 3;
|
|
307
|
+
const OPERAND_INDEX_4 = 4;
|
|
308
|
+
const OPERAND_INDEX_5 = 5;
|
|
309
|
+
const TZ_PERCENT_DIVISOR = 100;
|
|
277
310
|
function interpretContentStream(bytes, resources, context) {
|
|
278
|
-
|
|
279
|
-
runContentStream(bytes, resources, {
|
|
311
|
+
return runContentStream(bytes, resources, {
|
|
280
312
|
ctm: require_matrix.IDENTITY_MATRIX,
|
|
281
313
|
fillColor: document_schema_js.COLOR_BLACK,
|
|
282
314
|
strokeColor: document_schema_js.COLOR_BLACK,
|
|
283
315
|
lineWidth: DEFAULT_LINE_WIDTH_PT,
|
|
284
316
|
dashArray: [],
|
|
285
317
|
...initialTextParameters()
|
|
286
|
-
}, context,
|
|
287
|
-
return items;
|
|
318
|
+
}, context, 0, new MarkedContentStack());
|
|
288
319
|
}
|
|
289
320
|
function lastPointOf(subpath) {
|
|
290
321
|
const last = subpath.segments[subpath.segments.length - 1];
|
|
@@ -296,19 +327,15 @@ function lastPointOf(subpath) {
|
|
|
296
327
|
y: last.yPt
|
|
297
328
|
};
|
|
298
329
|
}
|
|
299
|
-
function runContentStream(bytes, resources, initialState, context,
|
|
330
|
+
function runContentStream(bytes, resources, initialState, context, depth, markedContent) {
|
|
331
|
+
const items = [];
|
|
300
332
|
const operations = require_content_read.readContentStream(bytes, context.sink);
|
|
301
333
|
const gsStack = [];
|
|
302
334
|
let gs = initialState;
|
|
303
335
|
let text = defaultTextObjectState();
|
|
304
336
|
let pathSubpaths = [];
|
|
305
337
|
let currentSubpath;
|
|
306
|
-
const inScope = (key) =>
|
|
307
|
-
for (let i = markedContent.length - 1; i >= 0; i--) {
|
|
308
|
-
const frame = markedContent[i];
|
|
309
|
-
if (frame !== void 0 && key in frame) return frame[key];
|
|
310
|
-
}
|
|
311
|
-
};
|
|
338
|
+
const inScope = (key) => markedContent.inScope(key);
|
|
312
339
|
const pushItem = (item) => {
|
|
313
340
|
if (item.kind === "text") {
|
|
314
341
|
const layer = item.layerName ?? inScope("layerName");
|
|
@@ -350,7 +377,7 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
350
377
|
const x = numAt(operands, 0);
|
|
351
378
|
const y = numAt(operands, 1);
|
|
352
379
|
const w = numAt(operands, 2);
|
|
353
|
-
const h = numAt(operands,
|
|
380
|
+
const h = numAt(operands, RE_HEIGHT_INDEX);
|
|
354
381
|
const p1 = require_matrix.applyMatrix(ctm, {
|
|
355
382
|
x,
|
|
356
383
|
y
|
|
@@ -432,10 +459,10 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
432
459
|
});
|
|
433
460
|
const widthPer1000 = glyph?.widthPer1000 ?? FALLBACK_GLYPH_WIDTH_PER_1000;
|
|
434
461
|
const byteLength = glyph?.byteLengthConsumed ?? 1;
|
|
435
|
-
const isSingleByteSpace = byteLength === 1 && codes[offset] ===
|
|
462
|
+
const isSingleByteSpace = byteLength === 1 && codes[offset] === ASCII_SPACE;
|
|
436
463
|
const spacing = gs.charSpace + (isSingleByteSpace ? gs.wordSpace : 0);
|
|
437
464
|
const vertical = glyph?.vertical;
|
|
438
|
-
text.tm = vertical === void 0 ? require_matrix.multiplyMatrices(require_matrix.translationMatrix((widthPer1000 /
|
|
465
|
+
text.tm = vertical === void 0 ? require_matrix.multiplyMatrices(require_matrix.translationMatrix((widthPer1000 / GLYPH_SPACE_PER_TEXT_SPACE_UNIT * gs.fontSizePt + spacing) * gs.horizScale, 0), text.tm) : require_matrix.multiplyMatrices(require_matrix.translationMatrix(0, vertical.displacementPer1000 / GLYPH_SPACE_PER_TEXT_SPACE_UNIT * gs.fontSizePt + spacing), text.tm);
|
|
439
466
|
offset += byteLength;
|
|
440
467
|
}
|
|
441
468
|
};
|
|
@@ -445,8 +472,8 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
445
472
|
const vertical = context.fontMetrics.glyphAdvance(fontResourceName, resources, codes, 0)?.vertical;
|
|
446
473
|
if (vertical === void 0) return;
|
|
447
474
|
return {
|
|
448
|
-
x: vertical.positionXPer1000 /
|
|
449
|
-
y: vertical.positionYPer1000 /
|
|
475
|
+
x: vertical.positionXPer1000 / GLYPH_SPACE_PER_TEXT_SPACE_UNIT,
|
|
476
|
+
y: vertical.positionYPer1000 / GLYPH_SPACE_PER_TEXT_SPACE_UNIT
|
|
450
477
|
};
|
|
451
478
|
};
|
|
452
479
|
const showTextArray = (elements) => {
|
|
@@ -463,7 +490,7 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
463
490
|
totalLength += el.bytes.length;
|
|
464
491
|
advanceThroughString(el.bytes);
|
|
465
492
|
} else if (el.kind === "number") {
|
|
466
|
-
const adjustment = -(el.value /
|
|
493
|
+
const adjustment = -(el.value / GLYPH_SPACE_PER_TEXT_SPACE_UNIT) * gs.fontSizePt;
|
|
467
494
|
text.tm = require_matrix.multiplyMatrices(vertical ? require_matrix.translationMatrix(0, adjustment) : require_matrix.translationMatrix(adjustment * gs.horizScale, 0), text.tm);
|
|
468
495
|
}
|
|
469
496
|
if (totalLength === 0) return;
|
|
@@ -541,10 +568,10 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
541
568
|
};
|
|
542
569
|
const formLayer = ownLayer ?? inScope("layerName");
|
|
543
570
|
const formMcid = require_objects.dictGet(xobj.dict, "StructParents") !== void 0 ? void 0 : inScope("mcid");
|
|
544
|
-
runContentStream(decoded.bytes, formResources, formState, context,
|
|
571
|
+
for (const formItem of runContentStream(decoded.bytes, formResources, formState, context, depth + 1, new MarkedContentStack([{
|
|
545
572
|
...formLayer !== void 0 ? { layerName: formLayer } : {},
|
|
546
573
|
...formMcid !== void 0 ? { mcid: formMcid } : {}
|
|
547
|
-
}]);
|
|
574
|
+
}]))) items.push(formItem);
|
|
548
575
|
}
|
|
549
576
|
};
|
|
550
577
|
for (const token of operations) {
|
|
@@ -661,11 +688,11 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
661
688
|
});
|
|
662
689
|
const c2 = require_matrix.applyMatrix(gs.ctm, {
|
|
663
690
|
x: numAt(operands, 2),
|
|
664
|
-
y: numAt(operands,
|
|
691
|
+
y: numAt(operands, OPERAND_INDEX_3)
|
|
665
692
|
});
|
|
666
693
|
const p = require_matrix.applyMatrix(gs.ctm, {
|
|
667
|
-
x: numAt(operands,
|
|
668
|
-
y: numAt(operands,
|
|
694
|
+
x: numAt(operands, OPERAND_INDEX_4),
|
|
695
|
+
y: numAt(operands, OPERAND_INDEX_5)
|
|
669
696
|
});
|
|
670
697
|
currentSubpath?.segments.push({
|
|
671
698
|
kind: "cubic",
|
|
@@ -687,7 +714,7 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
687
714
|
});
|
|
688
715
|
const p = require_matrix.applyMatrix(gs.ctm, {
|
|
689
716
|
x: numAt(operands, 2),
|
|
690
|
-
y: numAt(operands,
|
|
717
|
+
y: numAt(operands, OPERAND_INDEX_3)
|
|
691
718
|
});
|
|
692
719
|
currentSubpath.segments.push({
|
|
693
720
|
kind: "cubic",
|
|
@@ -707,7 +734,7 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
707
734
|
});
|
|
708
735
|
const p = require_matrix.applyMatrix(gs.ctm, {
|
|
709
736
|
x: numAt(operands, 2),
|
|
710
|
-
y: numAt(operands,
|
|
737
|
+
y: numAt(operands, OPERAND_INDEX_3)
|
|
711
738
|
});
|
|
712
739
|
currentSubpath?.segments.push({
|
|
713
740
|
kind: "cubic",
|
|
@@ -772,7 +799,7 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
772
799
|
case "Tz":
|
|
773
800
|
gs = {
|
|
774
801
|
...gs,
|
|
775
|
-
horizScale: numAt(operands, 0) /
|
|
802
|
+
horizScale: numAt(operands, 0) / TZ_PERCENT_DIVISOR
|
|
776
803
|
};
|
|
777
804
|
break;
|
|
778
805
|
case "TL":
|
|
@@ -843,18 +870,19 @@ function runContentStream(bytes, resources, initialState, context, items, depth,
|
|
|
843
870
|
...layerName !== void 0 ? { layerName } : {},
|
|
844
871
|
...markedContentScopeProps(props)
|
|
845
872
|
};
|
|
846
|
-
markedContent.
|
|
873
|
+
markedContent.open(depth === 0 ? scopeProps : {
|
|
847
874
|
...scopeProps,
|
|
848
875
|
mcid: void 0
|
|
849
876
|
});
|
|
850
877
|
break;
|
|
851
878
|
}
|
|
852
879
|
case "BMC":
|
|
853
|
-
markedContent.
|
|
880
|
+
markedContent.open({});
|
|
854
881
|
break;
|
|
855
|
-
case "EMC": markedContent.
|
|
882
|
+
case "EMC": markedContent.close();
|
|
856
883
|
}
|
|
857
884
|
}
|
|
885
|
+
return items;
|
|
858
886
|
}
|
|
859
887
|
//#endregion
|
|
860
888
|
exports.interpretContentStream = interpretContentStream;
|
package/dist/interpret.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.cjs";
|
|
2
2
|
import { r as Matrix } from "./matrix-B7_SBKQ5.cjs";
|
|
3
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
3
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.cjs";
|
|
4
4
|
import { Color, ContentStrokeStyle } from "document-schema.js";
|
|
5
5
|
//#region src/interpret.d.ts
|
|
6
6
|
interface ExtractedTextRun {
|
package/dist/interpret.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PdfDiagnosticSink } from "./diagnostics.js";
|
|
2
2
|
import { r as Matrix } from "./matrix-B7_SBKQ5.js";
|
|
3
|
-
import { n as PdfDict, r as PdfObject } from "./objects-
|
|
3
|
+
import { n as PdfDict, r as PdfObject } from "./objects-e2RS3-yT.js";
|
|
4
4
|
import { Color, ContentStrokeStyle } from "document-schema.js";
|
|
5
5
|
//#region src/interpret.d.ts
|
|
6
6
|
interface ExtractedTextRun {
|