reamkit 1.21.0 → 1.23.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/dist/esm/core/bytes.d.ts +22 -4
- package/dist/esm/core/bytes.js +73 -5
- package/dist/esm/core/converter/ream.d.ts +16 -0
- package/dist/esm/core/converter/ream.js +59 -9
- package/dist/esm/core/document-model/types.d.ts +78 -0
- package/dist/esm/core/drawingml/chart-geometry.js +11 -5
- package/dist/esm/core/drawingml/chart-parser.d.ts +2 -1
- package/dist/esm/core/drawingml/chart-parser.js +23 -1
- package/dist/esm/core/drawingml/colors.d.ts +30 -4
- package/dist/esm/core/drawingml/colors.js +45 -6
- package/dist/esm/core/drawingml/preset-geometry.js +236 -0
- package/dist/esm/core/drawingml/theme-parser.d.ts +38 -0
- package/dist/esm/core/drawingml/theme-parser.js +64 -1
- package/dist/esm/core/fonts/families.d.ts +10 -0
- package/dist/esm/core/fonts/families.js +44 -0
- package/dist/esm/core/fonts/index.d.ts +3 -2
- package/dist/esm/core/fonts/remote-fonts.d.ts +50 -0
- package/dist/esm/core/fonts/remote-fonts.js +114 -8
- package/dist/esm/core/fonts/scripts.d.ts +26 -0
- package/dist/esm/core/fonts/scripts.js +177 -0
- package/dist/esm/core/metafile/blit.d.ts +33 -0
- package/dist/esm/core/metafile/blit.js +67 -0
- package/dist/esm/core/metafile/dib.d.ts +61 -0
- package/dist/esm/core/metafile/dib.js +205 -0
- package/dist/esm/core/metafile/emf.js +139 -24
- package/dist/esm/core/metafile/picture.d.ts +12 -1
- package/dist/esm/core/metafile/symbol-fonts.d.ts +42 -0
- package/dist/esm/core/metafile/symbol-fonts.js +154 -0
- package/dist/esm/core/metafile/wmf.js +183 -10
- package/dist/esm/core/ole/escher-blip.d.ts +12 -0
- package/dist/esm/core/ole/escher-blip.js +88 -0
- package/dist/esm/{pdf-reader → core}/png-encode.js +1 -1
- package/dist/esm/core/vector.d.ts +5 -0
- package/dist/esm/excel/print-model.js +3 -1
- package/dist/esm/excel/sheet-shape-parser.js +1 -12
- package/dist/esm/excel/styles-parser.js +1 -1
- package/dist/esm/excel/xls/biff-reader.js +53 -18
- package/dist/esm/excel/xls/biff-styles.d.ts +5 -2
- package/dist/esm/excel/xls/biff-styles.js +9 -7
- package/dist/esm/excel/xls/escher.js +90 -24
- package/dist/esm/excel/xlsx-reader.d.ts +1 -1
- package/dist/esm/excel/xlsx-reader.js +3 -3
- package/dist/esm/layout/page-doc.d.ts +77 -0
- package/dist/esm/layout/page-doc.js +34 -18
- package/dist/esm/layout/styled-layout.d.ts +2 -2
- package/dist/esm/layout/styled-layout.js +467 -76
- package/dist/esm/pdf/shading.d.ts +19 -0
- package/dist/esm/pdf/shading.js +84 -11
- package/dist/esm/pdf/styled-page-emitter.js +647 -444
- package/dist/esm/pdf-reader/image-decode.js +1 -1
- package/dist/esm/pptx/embedded-fonts.d.ts +31 -0
- package/dist/esm/pptx/embedded-fonts.js +104 -0
- package/dist/esm/pptx/ole-preview.d.ts +10 -0
- package/dist/esm/pptx/ole-preview.js +52 -0
- package/dist/esm/pptx/placeholder-cascade.d.ts +136 -5
- package/dist/esm/pptx/placeholder-cascade.js +260 -27
- package/dist/esm/pptx/ppt/ppt-reader.js +120 -10
- package/dist/esm/pptx/ppt/ppt-text.d.ts +66 -1
- package/dist/esm/pptx/ppt/ppt-text.js +576 -137
- package/dist/esm/pptx/pptx-reader.d.ts +8 -0
- package/dist/esm/pptx/pptx-reader.js +271 -41
- package/dist/esm/pptx/preset-table-styles.d.ts +9 -0
- package/dist/esm/pptx/preset-table-styles.js +27 -0
- package/dist/esm/pptx/slide-parser.d.ts +78 -10
- package/dist/esm/pptx/slide-parser.js +396 -95
- package/dist/esm/pptx/sp-helpers.d.ts +2 -1
- package/dist/esm/pptx/sp-helpers.js +22 -6
- package/dist/esm/pptx/table-style.d.ts +64 -0
- package/dist/esm/pptx/table-style.js +203 -0
- package/dist/esm/svg/svg-writer.js +53 -5
- package/dist/esm/word/document-parser.d.ts +7 -1
- package/dist/esm/word/document-parser.js +6 -6
- package/dist/esm/word/docx-reader.js +8 -5
- package/dist/esm/word/docx-to-pdf.d.ts +8 -7
- package/dist/esm/word/docx-to-pdf.js +25 -7
- package/dist/esm/word/drawing-parser.d.ts +34 -0
- package/dist/esm/word/drawing-parser.js +173 -15
- package/dist/esm/word/numbering-parser.d.ts +2 -1
- package/dist/esm/word/numbering-parser.js +6 -6
- package/dist/esm/word/paragraph-properties.d.ts +2 -1
- package/dist/esm/word/paragraph-properties.js +2 -2
- package/dist/esm/word/run-properties.d.ts +5 -2
- package/dist/esm/word/run-properties.js +13 -8
- package/dist/esm/word/styles-parser.d.ts +2 -1
- package/dist/esm/word/styles-parser.js +12 -12
- package/dist/esm/word/table-parser.js +3 -3
- package/dist/esm/word/theme-fonts.d.ts +10 -0
- package/dist/esm/word/theme-fonts.js +28 -0
- package/package.json +1 -1
- /package/dist/esm/{pdf-reader → core}/png-encode.d.ts +0 -0
|
@@ -25,4 +25,23 @@ export declare function shapeBbox(shape: VectorShape): Bbox | undefined;
|
|
|
25
25
|
* @returns A reference to the `/Pattern` object, for a `/Pattern cs /Pn scn` fill.
|
|
26
26
|
*/
|
|
27
27
|
export declare function buildGradientPattern(doc: PdfDocument, gradient: ShapeGradient, bbox: Bbox, ctm: readonly [number, number, number, number, number, number]): PdfRef;
|
|
28
|
+
/**
|
|
29
|
+
* §11.6.5.2 — the luminosity soft mask a gradient with per-stop TRANSPARENCY is
|
|
30
|
+
* painted through.
|
|
31
|
+
*
|
|
32
|
+
* A PDF shading has one colour per point and no alpha, so a gradient that fades
|
|
33
|
+
* out is drawn as the colour shading masked by a second shading of the same
|
|
34
|
+
* geometry whose GREY is the transparency: white where the stop is opaque,
|
|
35
|
+
* black where it is clear. 45541_Footer's master lays a white band down the
|
|
36
|
+
* left of every slide that starts half transparent, and painted flat it covered
|
|
37
|
+
* the artwork behind it.
|
|
38
|
+
*
|
|
39
|
+
* @param doc The document to add the objects to.
|
|
40
|
+
* @param gradient The gradient fill.
|
|
41
|
+
* @param bbox The shape's local-space bounding box.
|
|
42
|
+
* @param ctm The shape's CTM, as the form's `/Matrix`.
|
|
43
|
+
* @returns The mask form XObject, or `undefined` when every stop is opaque or
|
|
44
|
+
* the sweep has no shading type that can carry a mask.
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildGradientAlphaMask(doc: PdfDocument, gradient: ShapeGradient, bbox: Bbox, ctm: readonly [number, number, number, number, number, number]): PdfRef | undefined;
|
|
28
47
|
export {};
|
package/dist/esm/pdf/shading.js
CHANGED
|
@@ -49,7 +49,7 @@ function buildGradientPattern(doc, gradient, bbox, ctm) {
|
|
|
49
49
|
Matrix: [...ctm]
|
|
50
50
|
}));
|
|
51
51
|
}
|
|
52
|
-
function axialShading(angleDeg, b, fnRef) {
|
|
52
|
+
function axialShading(angleDeg, b, fnRef, cs = "DeviceRGB") {
|
|
53
53
|
const rad = angleDeg * Math.PI / 180;
|
|
54
54
|
const dx = Math.cos(rad);
|
|
55
55
|
const dy = -Math.sin(rad);
|
|
@@ -70,7 +70,7 @@ function axialShading(angleDeg, b, fnRef) {
|
|
|
70
70
|
}
|
|
71
71
|
return dict({
|
|
72
72
|
ShadingType: 2,
|
|
73
|
-
ColorSpace: name(
|
|
73
|
+
ColorSpace: name(cs),
|
|
74
74
|
Coords: [
|
|
75
75
|
cx + (tmin - cproj) * dx,
|
|
76
76
|
cy + (tmin - cproj) * dy,
|
|
@@ -81,13 +81,13 @@ function axialShading(angleDeg, b, fnRef) {
|
|
|
81
81
|
Extend: [true, true]
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
-
function radialShading(b, fnRef, center) {
|
|
84
|
+
function radialShading(b, fnRef, center, cs = "DeviceRGB") {
|
|
85
85
|
const cx = center ? b.minX + center.x * (b.maxX - b.minX) : (b.minX + b.maxX) / 2;
|
|
86
86
|
const cy = center ? b.maxY - center.y * (b.maxY - b.minY) : (b.minY + b.maxY) / 2;
|
|
87
87
|
const r = Math.hypot(b.maxX - b.minX, b.maxY - b.minY) / 2;
|
|
88
88
|
return dict({
|
|
89
89
|
ShadingType: 3,
|
|
90
|
-
ColorSpace: name(
|
|
90
|
+
ColorSpace: name(cs),
|
|
91
91
|
Coords: [
|
|
92
92
|
cx,
|
|
93
93
|
cy,
|
|
@@ -171,6 +171,77 @@ function ps(n) {
|
|
|
171
171
|
const s = n.toFixed(6).replace(/0+$/u, "").replace(/\.$/u, "");
|
|
172
172
|
return s === "" || s === "-0" ? "0" : s;
|
|
173
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* §11.6.5.2 — the luminosity soft mask a gradient with per-stop TRANSPARENCY is
|
|
176
|
+
* painted through.
|
|
177
|
+
*
|
|
178
|
+
* A PDF shading has one colour per point and no alpha, so a gradient that fades
|
|
179
|
+
* out is drawn as the colour shading masked by a second shading of the same
|
|
180
|
+
* geometry whose GREY is the transparency: white where the stop is opaque,
|
|
181
|
+
* black where it is clear. 45541_Footer's master lays a white band down the
|
|
182
|
+
* left of every slide that starts half transparent, and painted flat it covered
|
|
183
|
+
* the artwork behind it.
|
|
184
|
+
*
|
|
185
|
+
* @param doc The document to add the objects to.
|
|
186
|
+
* @param gradient The gradient fill.
|
|
187
|
+
* @param bbox The shape's local-space bounding box.
|
|
188
|
+
* @param ctm The shape's CTM, as the form's `/Matrix`.
|
|
189
|
+
* @returns The mask form XObject, or `undefined` when every stop is opaque or
|
|
190
|
+
* the sweep has no shading type that can carry a mask.
|
|
191
|
+
*/
|
|
192
|
+
function buildGradientAlphaMask(doc, gradient, bbox, ctm) {
|
|
193
|
+
if (!gradient.stops.some((s) => (s.alpha ?? 1) < 1)) return void 0;
|
|
194
|
+
if (gradient.kind === "radial" && gradient.sweep === "rect") return void 0;
|
|
195
|
+
const fn = doc.add(buildAlphaRamp(gradient.stops));
|
|
196
|
+
const shading = gradient.kind === "radial" ? radialShading(bbox, fn, gradient.center, "DeviceGray") : axialShading(gradient.angle ?? 0, bbox, fn, "DeviceGray");
|
|
197
|
+
return doc.add(stream({
|
|
198
|
+
Type: name("XObject"),
|
|
199
|
+
Subtype: name("Form"),
|
|
200
|
+
BBox: [
|
|
201
|
+
bbox.minX,
|
|
202
|
+
bbox.minY,
|
|
203
|
+
bbox.maxX,
|
|
204
|
+
bbox.maxY
|
|
205
|
+
],
|
|
206
|
+
Matrix: [...ctm],
|
|
207
|
+
Group: dict({
|
|
208
|
+
S: name("Transparency"),
|
|
209
|
+
CS: name("DeviceGray")
|
|
210
|
+
}),
|
|
211
|
+
Resources: dict({ Shading: dict({ Sm: doc.add(shading) }) })
|
|
212
|
+
}, new TextEncoder().encode("q /Sm sh Q")));
|
|
213
|
+
}
|
|
214
|
+
function buildAlphaRamp(stopsIn) {
|
|
215
|
+
const stops = normalizeStops(stopsIn);
|
|
216
|
+
if (stops.length <= 2) return dict({
|
|
217
|
+
FunctionType: 2,
|
|
218
|
+
Domain: [0, 1],
|
|
219
|
+
C0: [stops[0].alpha],
|
|
220
|
+
C1: [stops[stops.length - 1].alpha],
|
|
221
|
+
N: 1
|
|
222
|
+
});
|
|
223
|
+
const functions = [];
|
|
224
|
+
const bounds = [];
|
|
225
|
+
const encode = [];
|
|
226
|
+
for (let i = 0; i < stops.length - 1; i++) {
|
|
227
|
+
functions.push(dict({
|
|
228
|
+
FunctionType: 2,
|
|
229
|
+
Domain: [0, 1],
|
|
230
|
+
C0: [stops[i].alpha],
|
|
231
|
+
C1: [stops[i + 1].alpha],
|
|
232
|
+
N: 1
|
|
233
|
+
}));
|
|
234
|
+
if (i > 0) bounds.push(stops[i].offset);
|
|
235
|
+
encode.push(0, 1);
|
|
236
|
+
}
|
|
237
|
+
return dict({
|
|
238
|
+
FunctionType: 3,
|
|
239
|
+
Domain: [0, 1],
|
|
240
|
+
Functions: functions,
|
|
241
|
+
Bounds: bounds,
|
|
242
|
+
Encode: encode
|
|
243
|
+
});
|
|
244
|
+
}
|
|
174
245
|
function buildRamp(stopsIn) {
|
|
175
246
|
const stops = normalizeStops(stopsIn);
|
|
176
247
|
if (stops.length <= 2) return dict({
|
|
@@ -205,19 +276,21 @@ function buildRamp(stopsIn) {
|
|
|
205
276
|
function normalizeStops(stops) {
|
|
206
277
|
const out = stops.map((s) => ({
|
|
207
278
|
offset: Math.max(0, Math.min(1, s.offset)),
|
|
208
|
-
colorHex: s.colorHex
|
|
279
|
+
colorHex: s.colorHex,
|
|
280
|
+
alpha: Math.max(0, Math.min(1, s.alpha ?? 1))
|
|
209
281
|
})).sort((a, b) => a.offset - b.offset);
|
|
210
282
|
if (out.length === 0) return [{
|
|
211
283
|
offset: 0,
|
|
212
|
-
colorHex: "000000"
|
|
284
|
+
colorHex: "000000",
|
|
285
|
+
alpha: 1
|
|
213
286
|
}];
|
|
214
287
|
out[0] = {
|
|
215
|
-
|
|
216
|
-
|
|
288
|
+
...out[0],
|
|
289
|
+
offset: 0
|
|
217
290
|
};
|
|
218
291
|
out[out.length - 1] = {
|
|
219
|
-
|
|
220
|
-
|
|
292
|
+
...out[out.length - 1],
|
|
293
|
+
offset: 1
|
|
221
294
|
};
|
|
222
295
|
return out;
|
|
223
296
|
}
|
|
@@ -235,4 +308,4 @@ function rgb01(hex) {
|
|
|
235
308
|
];
|
|
236
309
|
}
|
|
237
310
|
//#endregion
|
|
238
|
-
export { buildGradientPattern, shapeBbox };
|
|
311
|
+
export { buildGradientAlphaMask, buildGradientPattern, shapeBbox };
|