reamkit 1.26.0 → 1.28.0
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/README.md +14 -8
- package/dist/esm/core/converter/ream.d.ts +0 -9
- package/dist/esm/core/converter/ream.js +0 -1
- package/dist/esm/core/document-model/types.d.ts +5 -3
- package/dist/esm/core/font/index.d.ts +1 -0
- package/dist/esm/core/font/ligatures.d.ts +17 -0
- package/dist/esm/core/font/ligatures.js +49 -0
- package/dist/esm/core/font/ttf-parser.d.ts +2 -1
- package/dist/esm/core/font/ttf-parser.js +11 -2
- package/dist/esm/core/fonts/remote-fonts.d.ts +1 -1
- package/dist/esm/core/fonts/remote-fonts.js +47 -2
- package/dist/esm/core/fonts/scripts.js +10 -5
- package/dist/esm/excel/header-footer.js +53 -8
- package/dist/esm/layout/styled-layout.js +53 -3
- package/dist/esm/pdf/cid-font.js +35 -8
- package/dist/esm/pdf-reader/annot-draw.d.ts +65 -0
- package/dist/esm/pdf-reader/annot-draw.js +487 -0
- package/dist/esm/pdf-reader/annots.d.ts +0 -12
- package/dist/esm/pdf-reader/annots.js +30 -4
- package/dist/esm/pdf-reader/ccitt.d.ts +20 -3
- package/dist/esm/pdf-reader/ccitt.js +102 -6
- package/dist/esm/pdf-reader/cff-outline.d.ts +36 -0
- package/dist/esm/pdf-reader/cff-outline.js +1122 -0
- package/dist/esm/pdf-reader/cie-color.d.ts +33 -0
- package/dist/esm/pdf-reader/cie-color.js +112 -0
- package/dist/esm/pdf-reader/cmap.js +5 -2
- package/dist/esm/pdf-reader/content.d.ts +123 -3
- package/dist/esm/pdf-reader/content.js +232 -54
- package/dist/esm/pdf-reader/dingbats.d.ts +11 -0
- package/dist/esm/pdf-reader/dingbats.js +1033 -0
- package/dist/esm/pdf-reader/display.d.ts +1 -1
- package/dist/esm/pdf-reader/display.js +61 -6
- package/dist/esm/pdf-reader/document.d.ts +6 -0
- package/dist/esm/pdf-reader/document.js +55 -10
- package/dist/esm/pdf-reader/embedded-fonts.d.ts +23 -3
- package/dist/esm/pdf-reader/embedded-fonts.js +36 -4
- package/dist/esm/pdf-reader/encodings.d.ts +25 -0
- package/dist/esm/pdf-reader/encodings.js +110 -0
- package/dist/esm/pdf-reader/flow-build.d.ts +19 -5
- package/dist/esm/pdf-reader/flow-build.js +111 -11
- package/dist/esm/pdf-reader/font.js +403 -21
- package/dist/esm/pdf-reader/function.d.ts +16 -0
- package/dist/esm/pdf-reader/function.js +414 -0
- package/dist/esm/pdf-reader/glyf-outline.d.ts +43 -0
- package/dist/esm/pdf-reader/glyf-outline.js +351 -0
- package/dist/esm/pdf-reader/glyph-names.js +20 -0
- package/dist/esm/pdf-reader/icc.d.ts +10 -0
- package/dist/esm/pdf-reader/icc.js +210 -0
- package/dist/esm/pdf-reader/image-decode.d.ts +9 -4
- package/dist/esm/pdf-reader/image-decode.js +274 -72
- package/dist/esm/pdf-reader/images.d.ts +18 -0
- package/dist/esm/pdf-reader/images.js +154 -11
- package/dist/esm/pdf-reader/jbig2.d.ts +23 -0
- package/dist/esm/pdf-reader/jbig2.js +126 -32
- package/dist/esm/pdf-reader/layout.d.ts +32 -0
- package/dist/esm/pdf-reader/layout.js +1316 -64
- package/dist/esm/pdf-reader/lexer.d.ts +2 -0
- package/dist/esm/pdf-reader/lexer.js +4 -0
- package/dist/esm/pdf-reader/math-rows.d.ts +23 -0
- package/dist/esm/pdf-reader/math-rows.js +198 -0
- package/dist/esm/pdf-reader/optional-content.d.ts +36 -0
- package/dist/esm/pdf-reader/optional-content.js +93 -0
- package/dist/esm/pdf-reader/predefined-cmap.d.ts +21 -0
- package/dist/esm/pdf-reader/predefined-cmap.js +102 -0
- package/dist/esm/pdf-reader/reader.d.ts +6 -6
- package/dist/esm/pdf-reader/reader.js +102 -16
- package/dist/esm/pdf-reader/shading.d.ts +139 -8
- package/dist/esm/pdf-reader/shading.js +309 -39
- package/dist/esm/pdf-reader/standard-metrics.d.ts +8 -0
- package/dist/esm/pdf-reader/standard-metrics.js +18 -0
- package/dist/esm/pdf-reader/standard-widths.d.ts +20 -0
- package/dist/esm/pdf-reader/standard-widths.js +62 -0
- package/dist/esm/pdf-reader/stream-filters.d.ts +6 -0
- package/dist/esm/pdf-reader/stream-filters.js +67 -0
- package/dist/esm/pdf-reader/tagged.js +204 -32
- package/dist/esm/pdf-reader/text-rules.d.ts +16 -0
- package/dist/esm/pdf-reader/text-rules.js +185 -0
- package/dist/esm/pdf-reader/text.js +157 -4
- package/dist/esm/pdf-reader/type1-outline.d.ts +21 -0
- package/dist/esm/pdf-reader/type1-outline.js +576 -0
- package/dist/esm/pdf-reader/vector.d.ts +5 -0
- package/dist/esm/pdf-reader/vector.js +79 -27
- package/dist/esm/word/document-parser.js +4 -1
- package/dist/esm/word/docx-writer.js +74 -11
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** §8.6.5.6/§8.6.5.7 — what a CIE-based space states about itself. */
|
|
2
|
+
export interface CieSpace {
|
|
3
|
+
/** `/WhitePoint` — the colour of the illuminant, in XYZ. */
|
|
4
|
+
readonly white: readonly [number, number, number];
|
|
5
|
+
/** `/Gamma` — one per component. */
|
|
6
|
+
readonly gamma: ReadonlyArray<number>;
|
|
7
|
+
/** §8.6.5.7 `/Matrix` — components to XYZ, column-major as the PDF states it. */
|
|
8
|
+
readonly matrix?: ReadonlyArray<number>;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* One colour in a CIE-based space, as sRGB in 0..1.
|
|
12
|
+
*
|
|
13
|
+
* @param space The space's own parameters.
|
|
14
|
+
* @param abc Its components: one for a grey space, three for an RGB one.
|
|
15
|
+
* @returns The sRGB triple a viewer shows for it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function cieToSrgb(space: CieSpace, abc: ReadonlyArray<number>): [number, number, number];
|
|
18
|
+
/**
|
|
19
|
+
* §8.6.5.8 — one colour in a `Lab` space, as sRGB in 0..1.
|
|
20
|
+
*
|
|
21
|
+
* Lab is the one CIE space a file states in absolute terms: `L*` from 0 to 100
|
|
22
|
+
* is lightness and `a*`/`b*` are the two opponent axes, and unlike `CalRGB`
|
|
23
|
+
* (see the note above) there is no argument about the way out — every renderer
|
|
24
|
+
* takes it through XYZ against the stated white and adapts to the screen's.
|
|
25
|
+
* issue10339_reduced.pdf paints two grids of blue swatches through an `Indexed`
|
|
26
|
+
* palette whose base is one, and read as anything else the page came back
|
|
27
|
+
* blank.
|
|
28
|
+
*
|
|
29
|
+
* @param white The space's `/WhitePoint`, in XYZ.
|
|
30
|
+
* @param lab `L*`, `a*`, `b*`.
|
|
31
|
+
* @returns The sRGB triple a viewer shows for it.
|
|
32
|
+
*/
|
|
33
|
+
export declare function labToSrgb(white: readonly [number, number, number], lab: readonly [number, number, number]): [number, number, number];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//#region src/pdf-reader/cie-color.ts
|
|
2
|
+
/**
|
|
3
|
+
* One colour in a CIE-based space, as sRGB in 0..1.
|
|
4
|
+
*
|
|
5
|
+
* @param space The space's own parameters.
|
|
6
|
+
* @param abc Its components: one for a grey space, three for an RGB one.
|
|
7
|
+
* @returns The sRGB triple a viewer shows for it.
|
|
8
|
+
*/
|
|
9
|
+
function cieToSrgb(space, abc) {
|
|
10
|
+
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
11
|
+
if (space.matrix === void 0 || abc.length < 3) {
|
|
12
|
+
const v = srgbTransfer(clamp01(abc[0] ?? 0) ** (space.gamma[0] ?? 1));
|
|
13
|
+
return [
|
|
14
|
+
v,
|
|
15
|
+
v,
|
|
16
|
+
v
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
const m = space.matrix;
|
|
20
|
+
const a = clamp01(abc[0]) ** (space.gamma[0] ?? 1);
|
|
21
|
+
const b = clamp01(abc[1]) ** (space.gamma[1] ?? 1);
|
|
22
|
+
const c = clamp01(abc[2]) ** (space.gamma[2] ?? 1);
|
|
23
|
+
const [ax, ay, az] = adaptToD65((m[0] ?? 0) * a + (m[3] ?? 0) * b + (m[6] ?? 0) * c, (m[1] ?? 0) * a + (m[4] ?? 0) * b + (m[7] ?? 0) * c, (m[2] ?? 0) * a + (m[5] ?? 0) * b + (m[8] ?? 0) * c, space.white);
|
|
24
|
+
const r = 3.2404542 * ax - 1.5371385 * ay - .4985314 * az;
|
|
25
|
+
const g = -.969266 * ax + 1.8760108 * ay + .041556 * az;
|
|
26
|
+
const bl = .0556434 * ax - .2040259 * ay + 1.0572252 * az;
|
|
27
|
+
return [
|
|
28
|
+
srgbTransfer(clamp01(r)),
|
|
29
|
+
srgbTransfer(clamp01(g)),
|
|
30
|
+
srgbTransfer(clamp01(bl))
|
|
31
|
+
];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* §8.6.5.8 — one colour in a `Lab` space, as sRGB in 0..1.
|
|
35
|
+
*
|
|
36
|
+
* Lab is the one CIE space a file states in absolute terms: `L*` from 0 to 100
|
|
37
|
+
* is lightness and `a*`/`b*` are the two opponent axes, and unlike `CalRGB`
|
|
38
|
+
* (see the note above) there is no argument about the way out — every renderer
|
|
39
|
+
* takes it through XYZ against the stated white and adapts to the screen's.
|
|
40
|
+
* issue10339_reduced.pdf paints two grids of blue swatches through an `Indexed`
|
|
41
|
+
* palette whose base is one, and read as anything else the page came back
|
|
42
|
+
* blank.
|
|
43
|
+
*
|
|
44
|
+
* @param white The space's `/WhitePoint`, in XYZ.
|
|
45
|
+
* @param lab `L*`, `a*`, `b*`.
|
|
46
|
+
* @returns The sRGB triple a viewer shows for it.
|
|
47
|
+
*/
|
|
48
|
+
function labToSrgb(white, lab) {
|
|
49
|
+
const m = (Math.min(100, Math.max(0, lab[0])) + 16) / 116;
|
|
50
|
+
const l = m + lab[1] / 500;
|
|
51
|
+
const n = m - lab[2] / 200;
|
|
52
|
+
const [ax, ay, az] = adaptToD65(white[0] * inverseTransfer(l), white[1] * inverseTransfer(m), white[2] * inverseTransfer(n), white);
|
|
53
|
+
const r = 3.2404542 * ax - 1.5371385 * ay - .4985314 * az;
|
|
54
|
+
const g = -.969266 * ax + 1.8760108 * ay + .041556 * az;
|
|
55
|
+
const b = .0556434 * ax - .2040259 * ay + 1.0572252 * az;
|
|
56
|
+
const clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
57
|
+
return [
|
|
58
|
+
srgbTransfer(clamp01(r)),
|
|
59
|
+
srgbTransfer(clamp01(g)),
|
|
60
|
+
srgbTransfer(clamp01(b))
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
/** §8.6.5.8 — the `g` of the Lab definition, which is a cube with a linear toe. */
|
|
64
|
+
function inverseTransfer(v) {
|
|
65
|
+
return v >= 6 / 29 ? v ** 3 : 108 / 841 * (v - 4 / 29);
|
|
66
|
+
}
|
|
67
|
+
/** The D65 white every sRGB screen is referred to. */
|
|
68
|
+
var D65 = [
|
|
69
|
+
.9505,
|
|
70
|
+
1,
|
|
71
|
+
1.089
|
|
72
|
+
];
|
|
73
|
+
/**
|
|
74
|
+
* Bradford chromatic adaptation from the space's own white to D65.
|
|
75
|
+
*
|
|
76
|
+
* A file may state any illuminant — calrgb.pdf states several — and a colour
|
|
77
|
+
* measured against one white shown against another is the wrong colour. The
|
|
78
|
+
* Bradford transform is the one every colour-managed renderer uses for this.
|
|
79
|
+
*/
|
|
80
|
+
function adaptToD65(x, y, z, white) {
|
|
81
|
+
const [sx, sy, sz] = coneResponse(white[0], white[1], white[2]);
|
|
82
|
+
const [dx, dy, dz] = coneResponse(D65[0], D65[1], D65[2]);
|
|
83
|
+
if (sx === 0 || sy === 0 || sz === 0) return [
|
|
84
|
+
x,
|
|
85
|
+
y,
|
|
86
|
+
z
|
|
87
|
+
];
|
|
88
|
+
const [cx, cy, cz] = coneResponse(x, y, z);
|
|
89
|
+
return fromConeResponse(cx * dx / sx, cy * dy / sy, cz * dz / sz);
|
|
90
|
+
}
|
|
91
|
+
/** XYZ into the Bradford cone-response space. */
|
|
92
|
+
function coneResponse(x, y, z) {
|
|
93
|
+
return [
|
|
94
|
+
.8951 * x + .2664 * y - .1614 * z,
|
|
95
|
+
-.7502 * x + 1.7135 * y + .0367 * z,
|
|
96
|
+
.0389 * x - .0685 * y + 1.0296 * z
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
/** …and back out of it. */
|
|
100
|
+
function fromConeResponse(l, m, s) {
|
|
101
|
+
return [
|
|
102
|
+
.9869929 * l - .1470543 * m + .1599627 * s,
|
|
103
|
+
.4323053 * l + .5183603 * m + .0492912 * s,
|
|
104
|
+
-.0085287 * l + .0400428 * m + .9684867 * s
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
/** IEC 61966-2-1 — linear light to the sRGB signal a screen takes. */
|
|
108
|
+
function srgbTransfer(v) {
|
|
109
|
+
return v <= .0031308 ? 12.92 * v : 1.055 * v ** (1 / 2.4) - .055;
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { cieToSrgb, labToSrgb };
|
|
@@ -74,8 +74,11 @@ function utf16be(bytes) {
|
|
|
74
74
|
}
|
|
75
75
|
function incString(base, i) {
|
|
76
76
|
if (i === 0) return base;
|
|
77
|
-
|
|
78
|
-
return base;
|
|
77
|
+
const chars = [...base];
|
|
78
|
+
if (chars.length === 0) return base;
|
|
79
|
+
const last = chars[chars.length - 1].codePointAt(0) + i;
|
|
80
|
+
if (last > 1114111 || last >= 55296 && last <= 57343) return base;
|
|
81
|
+
return chars.slice(0, -1).join("") + String.fromCodePoint(last);
|
|
79
82
|
}
|
|
80
83
|
//#endregion
|
|
81
84
|
export { parseToUnicodeCMap };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ColorSpaceInfo } from './shading.js';
|
|
1
|
+
import { ColorSpaceInfo, GsPaint } from './shading.js';
|
|
2
|
+
import { TextMarkup } from './annot-draw.js';
|
|
2
3
|
import { ShapeGradient } from '../core/vector.js';
|
|
3
4
|
import { PdfDict, PdfStream } from '../pdf/objects.js';
|
|
4
5
|
/**
|
|
@@ -10,10 +11,25 @@ import { PdfDict, PdfStream } from '../pdf/objects.js';
|
|
|
10
11
|
export interface ContentFont {
|
|
11
12
|
/** Bytes per character code: simple fonts read 1 byte/code, Type0 reads 2. */
|
|
12
13
|
readonly bytesPerCode: 1 | 2;
|
|
14
|
+
/**
|
|
15
|
+
* §9.7.6.2 — how a shown string breaks into codes, where the CMap is not
|
|
16
|
+
* fixed-width. A named CMap like `90ms-RKSJ-H` mixes one-byte and two-byte
|
|
17
|
+
* codes, and split down the middle a Japanese line came apart into nonsense.
|
|
18
|
+
* Absent means the fixed width above.
|
|
19
|
+
*/
|
|
20
|
+
readonly splitCodes?: (bytes: Uint8Array) => Array<number>;
|
|
13
21
|
/** Decode a sequence of character codes to a Unicode string. */
|
|
14
22
|
decode: (codes: ReadonlyArray<number>) => string;
|
|
15
23
|
/** Glyph advance for one code, in 1000-unit text space. */
|
|
16
24
|
width: (code: number) => number;
|
|
25
|
+
/**
|
|
26
|
+
* §9.4.4 / §9.7.4.3 — the face sets its text DOWN the page, not across, and
|
|
27
|
+
* the pen advances by the vertical displacement `w1` rather than by `w0`.
|
|
28
|
+
* A `…-V` CMap asks for this; `/DW2`'s default `[880 -1000]` is one em down.
|
|
29
|
+
* The number here is that displacement in 1000-unit text space, and it is
|
|
30
|
+
* negative because the page's y runs up.
|
|
31
|
+
*/
|
|
32
|
+
readonly verticalAdvance?: (code: number) => number;
|
|
17
33
|
/** §9.6.2 — the face's own `/BaseFont` name, for a document that embeds it. */
|
|
18
34
|
readonly name?: string;
|
|
19
35
|
/** §9.8.1 — the face is a bold one (weight, the ForceBold flag, or its name). */
|
|
@@ -26,6 +42,19 @@ export interface ContentFont {
|
|
|
26
42
|
* procedure paints, in the resources the font states.
|
|
27
43
|
*/
|
|
28
44
|
readonly type3?: Type3Face;
|
|
45
|
+
/**
|
|
46
|
+
* §9.6.6 — the OUTLINE a code draws, for a code that stands for no
|
|
47
|
+
* character. A face that can say what its characters are never has one:
|
|
48
|
+
* this is the last resort before a blank page.
|
|
49
|
+
*/
|
|
50
|
+
readonly outline?: GlyphOutline;
|
|
51
|
+
}
|
|
52
|
+
/** §9.6.6 — the outlines of a face read by glyph index, and their glyph space. */
|
|
53
|
+
export interface GlyphOutline {
|
|
54
|
+
/** Glyph space to text space, as a Type 3 font's `/FontMatrix` is. */
|
|
55
|
+
readonly matrix: Matrix;
|
|
56
|
+
/** The contours one code draws, or `undefined` where it draws none. */
|
|
57
|
+
readonly path: (code: number) => Array<PathSeg> | undefined;
|
|
29
58
|
}
|
|
30
59
|
/** §9.6.5 — the parts of a Type 3 font a caller needs to run its glyphs. */
|
|
31
60
|
export interface Type3Face {
|
|
@@ -72,14 +101,33 @@ export interface TextRun {
|
|
|
72
101
|
* than in a substitute (see `./embedded-fonts`).
|
|
73
102
|
*/
|
|
74
103
|
readonly fontName?: string;
|
|
104
|
+
/**
|
|
105
|
+
* §9.4.4 — the advance of this face's SPACE at the size the run was shown
|
|
106
|
+
* at, which is what says whether a gap between two runs was a word space.
|
|
107
|
+
* Absent where the face states no width for it.
|
|
108
|
+
*/
|
|
109
|
+
readonly spaceWidthPt?: number;
|
|
75
110
|
/** §9.8.1 — the face the glyphs were shown in is a bold one. */
|
|
76
111
|
readonly bold?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* §12.5.6.10 — a text-markup annotation marks these glyphs: highlighted,
|
|
114
|
+
* underlined, struck through. Applied after extraction, from the page's
|
|
115
|
+
* `/Annots` (see `./text`), because it is stated about the words rather than
|
|
116
|
+
* painted among them.
|
|
117
|
+
*/
|
|
118
|
+
readonly markup?: TextMarkup;
|
|
77
119
|
/**
|
|
78
120
|
* §8.6.6.2 — the glyphs are filled with a tiling PATTERN, named here for the
|
|
79
121
|
* caller to resolve: a pattern is a content stream, not a colour, and the
|
|
80
122
|
* fill colour still standing from before is not what the page shows.
|
|
81
123
|
*/
|
|
82
124
|
readonly fillPatternName?: string;
|
|
125
|
+
/**
|
|
126
|
+
* §8.7.4.5 — the glyphs are filled with a SHADING pattern: a sweep from one
|
|
127
|
+
* colour to another, of which the run carries the middle. The colour is not
|
|
128
|
+
* lost, the shape of it is.
|
|
129
|
+
*/
|
|
130
|
+
readonly gradientFill?: boolean;
|
|
83
131
|
/**
|
|
84
132
|
* §9.3.6 — the page painted these glyphs NOWHERE: mode 3 shows nothing and
|
|
85
133
|
* mode 7 only adds to the clip. A scanned page carries its recognised words
|
|
@@ -120,13 +168,35 @@ export interface TextRun {
|
|
|
120
168
|
* square to page space, so it carries both the placement and the size; the
|
|
121
169
|
* `mcid` links the paint to its structure element (a `/Figure`, E-PDF EP6).
|
|
122
170
|
*/
|
|
171
|
+
/** §8.9.7 — an image written into the content stream rather than named. */
|
|
172
|
+
export interface InlineImage {
|
|
173
|
+
/** Its dictionary, keys as written — the abbreviated ones (`/W`, `/CS`, `/F`). */
|
|
174
|
+
readonly dict: PdfDict;
|
|
175
|
+
/** Its bytes, still filtered as the dictionary says. */
|
|
176
|
+
readonly data: Uint8Array;
|
|
177
|
+
}
|
|
123
178
|
export interface ImagePlacement {
|
|
124
179
|
/** Where the `Do` fell in the stream's painting order — see {@link VectorPlacement.order}. */
|
|
125
180
|
readonly order: number;
|
|
126
|
-
/** XObject resource name (no leading slash). */
|
|
181
|
+
/** XObject resource name (no leading slash), empty for an inline image. */
|
|
127
182
|
readonly name: string;
|
|
183
|
+
/** §8.9.7 — the image itself, where it was written into the stream. */
|
|
184
|
+
readonly inline?: InlineImage;
|
|
128
185
|
readonly ctm: Matrix;
|
|
186
|
+
/** §8.5.4 — the clip in force when it was painted, when there was one. */
|
|
187
|
+
readonly clip?: ClipRegion;
|
|
188
|
+
/**
|
|
189
|
+
* §8.9.6.2 — the non-stroking colour in force. A stencil `/ImageMask` carries
|
|
190
|
+
* no colour of its own: it says only WHERE to paint, and this is what.
|
|
191
|
+
*/
|
|
192
|
+
readonly fillHex: string;
|
|
129
193
|
readonly mcid?: number;
|
|
194
|
+
/** §11.6.4.4 `/ca` — how opaque the picture is drawn, when the page asked for less. */
|
|
195
|
+
readonly alpha?: number;
|
|
196
|
+
/** §11.3.5 `/BM` — a blend the page asked for that nothing here performs. */
|
|
197
|
+
readonly blend?: string;
|
|
198
|
+
/** §11.6.5 `/SMask` — the paint faded from place to place; nothing here does. */
|
|
199
|
+
readonly masked?: boolean;
|
|
130
200
|
}
|
|
131
201
|
/**
|
|
132
202
|
* One segment of a painted path (E-PDF EP10/EP11), in page space (y-up): a
|
|
@@ -178,6 +248,23 @@ export interface VectorPlacement {
|
|
|
178
248
|
readonly gradient?: ShapeGradient;
|
|
179
249
|
/** §11.6.4.4 `/ca` — how opaque the fill is, when the page asked for less. */
|
|
180
250
|
readonly alpha?: number;
|
|
251
|
+
/**
|
|
252
|
+
* §11.3.5 `/BM` — the fill only DARKENS what it covers (`Multiply`,
|
|
253
|
+
* `Darken`), so the marks under it read through. A highlighter is this and
|
|
254
|
+
* nothing else.
|
|
255
|
+
*/
|
|
256
|
+
readonly darkens?: boolean;
|
|
257
|
+
/** §11.3.5 `/BM` — a blend the page asked for that nothing here performs. */
|
|
258
|
+
readonly blend?: string;
|
|
259
|
+
/** §11.6.5 `/SMask` — the paint faded from place to place; nothing here does. */
|
|
260
|
+
readonly masked?: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* §9.6.6 — this path is a GLYPH, traced from the face because its code stands
|
|
263
|
+
* for no character. It is type, not artwork, so the de-cluttering a page's
|
|
264
|
+
* paths go through does not apply: a full stop is a mark one point across and
|
|
265
|
+
* every filter there would throw it out.
|
|
266
|
+
*/
|
|
267
|
+
readonly glyph?: boolean;
|
|
181
268
|
/**
|
|
182
269
|
* §8.7.3 — the TILING pattern resource name the path is filled with. Its
|
|
183
270
|
* content is a stream of its own, so what the fill actually shows is only
|
|
@@ -197,11 +284,44 @@ export interface InterpretResult {
|
|
|
197
284
|
readonly vectors: Array<VectorPlacement>;
|
|
198
285
|
/** §9.6.5 — every Type 3 glyph the stream showed, with where to run it. */
|
|
199
286
|
readonly glyphs: Array<Type3Call>;
|
|
287
|
+
/**
|
|
288
|
+
* §8.7.4.3 — every region the stream painted with a bare `sh`, which fills
|
|
289
|
+
* the CLIP rather than a path. What a caller can do with one depends on the
|
|
290
|
+
* shading's own type, so the placement is carried rather than counted.
|
|
291
|
+
*/
|
|
292
|
+
readonly shadings: Array<ShadingPaint>;
|
|
293
|
+
/**
|
|
294
|
+
* §9.6.6 — every glyph the stream showed that stands for NO character, as
|
|
295
|
+
* the path it draws in page space. There is nothing to write for one, and
|
|
296
|
+
* there is something to draw.
|
|
297
|
+
*/
|
|
298
|
+
readonly outlines: Array<VectorPlacement>;
|
|
200
299
|
}
|
|
201
300
|
/**
|
|
202
301
|
* §9.6.5 — one showing of a Type 3 glyph: which procedure, and the matrix that
|
|
203
302
|
* puts glyph space on the page.
|
|
204
303
|
*/
|
|
304
|
+
/** §8.7.4.3 — one `sh`: which shading, where the CTM put it, what bounded it. */
|
|
305
|
+
export interface ShadingPaint {
|
|
306
|
+
/** The `/Shading` resource name (no leading slash). */
|
|
307
|
+
readonly name: string;
|
|
308
|
+
/** The CTM in force, which maps the shading's own space onto the page. */
|
|
309
|
+
readonly ctm: Matrix;
|
|
310
|
+
/** §8.5.4 — the clip the paint was bounded by, which is its whole extent. */
|
|
311
|
+
readonly clip?: ClipRegion;
|
|
312
|
+
/**
|
|
313
|
+
* §11.6.5 `/SMask` — the paint was faded from place to place. For a `sh` that
|
|
314
|
+
* is not a detail: the mask is the SHAPE, and the clip is only its outer
|
|
315
|
+
* bound.
|
|
316
|
+
*/
|
|
317
|
+
readonly masked?: boolean;
|
|
318
|
+
/** §11.6.4.4 `/ca` — how opaque the paint is, when the page asked for less. */
|
|
319
|
+
readonly alpha?: number;
|
|
320
|
+
/** §11.3.5 `/BM` — the paint only DARKENS what it covers. */
|
|
321
|
+
readonly darkens?: boolean;
|
|
322
|
+
/** Where it fell in the painting order (§8.5.3). */
|
|
323
|
+
readonly order: number;
|
|
324
|
+
}
|
|
205
325
|
export interface Type3Call {
|
|
206
326
|
readonly stream: PdfStream;
|
|
207
327
|
readonly resources: PdfDict | undefined;
|
|
@@ -222,7 +342,7 @@ export type Matrix = readonly [number, number, number, number, number, number];
|
|
|
222
342
|
export declare const IDENTITY: Matrix;
|
|
223
343
|
/** Compose two {@link Matrix matrices}: `a` applied first, then `b`. */
|
|
224
344
|
export declare function multiply(a: Matrix, b: Matrix): Matrix;
|
|
225
|
-
export declare function interpretContent(bytes: Uint8Array, fonts: ReadonlyMap<string, ContentFont>, initialCtm?: Matrix, shadings?: ReadonlyMap<string, ShapeGradient>, alphas?: ReadonlyMap<string,
|
|
345
|
+
export declare function interpretContent(bytes: Uint8Array, fonts: ReadonlyMap<string, ContentFont>, initialCtm?: Matrix, shadings?: ReadonlyMap<string, ShapeGradient>, alphas?: ReadonlyMap<string, GsPaint>, spaces?: ReadonlyMap<string, ColorSpaceInfo>, hiddenOc?: ReadonlySet<string>): InterpretResult;
|
|
226
346
|
/**
|
|
227
347
|
* Whether a string is wholly right-to-left: at least one letter of an RTL
|
|
228
348
|
* script and nothing of any other, spaces and joiners aside.
|