pptx-glimpse 1.1.2 → 2.0.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/index.cjs +7090 -9103
- package/dist/index.d.cts +400 -66
- package/dist/index.d.ts +400 -66
- package/dist/index.js +7089 -9102
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Source handle related types.
|
|
3
|
+
*
|
|
4
|
+
* PptxSourceModel source node is a writer / editor / round-trip
|
|
5
|
+
* In order to do this, we can use ``which package part and which node it came from'' as a stable handle.
|
|
6
|
+
* A handle is not a direct mutable pointer, but a stable reference
|
|
7
|
+
* (see part path / relationship id / node id / order within siblings / raw sidecar)
|
|
8
|
+
* composes it.
|
|
9
|
+
*/
|
|
10
|
+
declare const PartPathBrand: unique symbol;
|
|
11
|
+
declare const RelationshipIdBrand: unique symbol;
|
|
12
|
+
declare const SourceNodeIdBrand: unique symbol;
|
|
13
|
+
declare const RawSidecarIdBrand: unique symbol;
|
|
14
|
+
/** Part path inside the OOXML package (Example: `ppt/slides/slide1.xml`). */
|
|
15
|
+
type PartPath = string & {
|
|
16
|
+
readonly [PartPathBrand]: typeof PartPathBrand;
|
|
17
|
+
};
|
|
18
|
+
/** Relationship id (Example: `rId1`).`_rels/*.rels` source. */
|
|
19
|
+
type RelationshipId = string & {
|
|
20
|
+
readonly [RelationshipIdBrand]: typeof RelationshipIdBrand;
|
|
21
|
+
};
|
|
22
|
+
/** An id that uniquely points to an element within the source part (spid / generation id, etc.). */
|
|
23
|
+
type SourceNodeId = string & {
|
|
24
|
+
readonly [SourceNodeIdBrand]: typeof SourceNodeIdBrand;
|
|
25
|
+
};
|
|
26
|
+
/** Id pointing to a raw sidecar. */
|
|
27
|
+
type RawSidecarId = string & {
|
|
28
|
+
readonly [RawSidecarIdBrand]: typeof RawSidecarIdBrand;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Stable handle describing a source node's provenance. The writer uses the handle to decide whether a generated
|
|
32
|
+
* node can be spliced into an existing part or whether a broader scope must be regenerated.
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
interface SourceHandle {
|
|
36
|
+
/** Package part that owns this node. */
|
|
37
|
+
readonly partPath: PartPath;
|
|
38
|
+
/** Node id inside the part (when available). */
|
|
39
|
+
readonly nodeId?: SourceNodeId;
|
|
40
|
+
/** The relationship id referencing this node (e.g. `r:embed` in blip). */
|
|
41
|
+
readonly relationshipId?: RelationshipId;
|
|
42
|
+
/** The child's order slot within the parent element. Used to restore order with raw sidecar. */
|
|
43
|
+
readonly orderingSlot?: number;
|
|
44
|
+
/** Raw sidecar ids associated with this node. */
|
|
45
|
+
readonly rawSidecarIds?: readonly RawSidecarId[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Font resolver context for text-to-path conversion.
|
|
50
|
+
* Provides access to a Font object with the opentype.js getPath() method.
|
|
4
51
|
*/
|
|
5
52
|
interface OpentypePath {
|
|
6
53
|
toPathData(decimalPlaces?: number): string;
|
|
@@ -17,49 +64,70 @@ interface TextPathFontResolver {
|
|
|
17
64
|
}
|
|
18
65
|
|
|
19
66
|
/**
|
|
20
|
-
* PPTX
|
|
21
|
-
*
|
|
67
|
+
* Mapping from PPTX font family names to replacement font family names.
|
|
68
|
+
*
|
|
69
|
+
* Keys are font names found in PPTX files. Values are font names that should be
|
|
70
|
+
* present in the rendering environment, commonly open-source alternatives to
|
|
71
|
+
* proprietary Microsoft Office fonts.
|
|
22
72
|
*/
|
|
23
|
-
/** フォントマッピングテーブルの型 */
|
|
24
73
|
type FontMapping = Record<string, string>;
|
|
25
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Default replacement mapping for common Microsoft Office fonts.
|
|
76
|
+
*
|
|
77
|
+
* The table maps fonts such as Calibri, Arial, Meiryo, and MS Gothic to
|
|
78
|
+
* open-source alternatives used during text measurement, SVG path generation,
|
|
79
|
+
* and font lookup.
|
|
80
|
+
*/
|
|
26
81
|
declare const DEFAULT_FONT_MAPPING: Readonly<FontMapping>;
|
|
27
82
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
83
|
+
* Create a font mapping table by merging defaults with user overrides.
|
|
84
|
+
*
|
|
85
|
+
* @param userMapping Custom PPTX font name to replacement font name entries.
|
|
86
|
+
* User-specified entries take precedence over `DEFAULT_FONT_MAPPING`.
|
|
87
|
+
* @returns A new mutable mapping object.
|
|
30
88
|
*/
|
|
31
89
|
declare function createFontMapping(userMapping?: FontMapping): FontMapping;
|
|
90
|
+
/**
|
|
91
|
+
* Look up the replacement font for a PPTX font family.
|
|
92
|
+
*
|
|
93
|
+
* Matching is case-insensitive and normalizes full-width alphanumeric
|
|
94
|
+
* characters used by some Japanese Office font names.
|
|
95
|
+
*
|
|
96
|
+
* @param fontFamily PPTX font family name to resolve.
|
|
97
|
+
* @param mapping Mapping table, usually from `createFontMapping`.
|
|
98
|
+
* @returns The replacement font name, or `null` when no mapping exists.
|
|
99
|
+
*/
|
|
32
100
|
declare function getMappedFont(fontFamily: string | null | undefined, mapping: FontMapping): string | null;
|
|
33
101
|
|
|
34
102
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* Canvas API
|
|
103
|
+
* Interface for measuring text width and line height.
|
|
104
|
+
* By default, measurement uses static font metrics.
|
|
105
|
+
* Users can pass their own implementation to ConvertOptions.textMeasurer
|
|
106
|
+
* Can be replaced with any measurement backend such as Canvas API or opentype.js.
|
|
39
107
|
*/
|
|
40
108
|
interface TextMeasurer {
|
|
41
109
|
/**
|
|
42
|
-
*
|
|
43
|
-
* @param text -
|
|
44
|
-
* @param fontSizePt -
|
|
45
|
-
* @param bold -
|
|
46
|
-
* @param fontFamily -
|
|
47
|
-
* @param fontFamilyEa -
|
|
110
|
+
* Returns the estimated width of the text in pixels.
|
|
111
|
+
* @param text - text to measure
|
|
112
|
+
* @param fontSizePt - font size (points)
|
|
113
|
+
* @param bold - whether the text is bold
|
|
114
|
+
* @param fontFamily - font family name for Latin text
|
|
115
|
+
* @param fontFamilyEa - font family name for East Asian text
|
|
48
116
|
*/
|
|
49
117
|
measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
|
|
50
118
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @param fontFamily -
|
|
54
|
-
* @param fontFamilyEa -
|
|
119
|
+
* Returns the font's natural line height ratio (line height / font size).
|
|
120
|
+
* Returns 1.2 as a fallback value if the metric is unknown.
|
|
121
|
+
* @param fontFamily - font family name for Latin text
|
|
122
|
+
* @param fontFamilyEa - font family name for East Asian text
|
|
55
123
|
*/
|
|
56
124
|
getLineHeightRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
|
|
57
125
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @param fontFamily -
|
|
62
|
-
* @param fontFamilyEa -
|
|
126
|
+
* Font ascender ratio (ascender / unitsPerEm) .
|
|
127
|
+
* Used for baseline offset calculation in the first row.
|
|
128
|
+
* Returns 1.0 as a fallback value if the metric is unknown.
|
|
129
|
+
* @param fontFamily - font family name for Latin text
|
|
130
|
+
* @param fontFamilyEa - font family name for East Asian text
|
|
63
131
|
*/
|
|
64
132
|
getAscenderRatio(fontFamily?: string | null, fontFamilyEa?: string | null): number;
|
|
65
133
|
}
|
|
@@ -78,8 +146,8 @@ declare class OpentypeTextMeasurer implements TextMeasurer {
|
|
|
78
146
|
private defaultFont;
|
|
79
147
|
private warnedFonts;
|
|
80
148
|
/**
|
|
81
|
-
* @param fonts -
|
|
82
|
-
* @param defaultFont -
|
|
149
|
+
* @param fonts - font name -> opentype.js Map of Font objects
|
|
150
|
+
* @param defaultFont - fallback font (optional)
|
|
83
151
|
*/
|
|
84
152
|
constructor(fonts: Map<string, OpentypeFont>, defaultFont?: OpentypeFont);
|
|
85
153
|
measureTextWidth(text: string, fontSizePt: number, bold: boolean, fontFamily?: string | null, fontFamilyEa?: string | null): number;
|
|
@@ -89,119 +157,385 @@ declare class OpentypeTextMeasurer implements TextMeasurer {
|
|
|
89
157
|
private resolveFont;
|
|
90
158
|
}
|
|
91
159
|
|
|
92
|
-
/**
|
|
160
|
+
/**
|
|
161
|
+
* Font file data supplied directly by the caller.
|
|
162
|
+
*
|
|
163
|
+
* Use this when system font scanning is unavailable or undesirable, such as in
|
|
164
|
+
* serverless environments. `name` is used to register TTF/OTF buffers under a
|
|
165
|
+
* specific family name; TTC buffers also read family names from their names
|
|
166
|
+
* table.
|
|
167
|
+
*/
|
|
93
168
|
interface FontBuffer {
|
|
169
|
+
/**
|
|
170
|
+
* Optional font family name to register for this buffer.
|
|
171
|
+
*/
|
|
94
172
|
name?: string;
|
|
173
|
+
/**
|
|
174
|
+
* Raw TTF, OTF, or TTC font file bytes.
|
|
175
|
+
*/
|
|
95
176
|
data: ArrayBuffer | Uint8Array;
|
|
96
177
|
}
|
|
97
178
|
/**
|
|
98
|
-
*
|
|
179
|
+
* Create a text measurer from caller-provided font buffers.
|
|
99
180
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
181
|
+
* This low-level helper is useful when rendering in an environment where fonts
|
|
182
|
+
* are bundled as bytes instead of discovered from the OS. It dynamically imports
|
|
183
|
+
* `opentype.js` and returns `null` if no fonts can be parsed or the optional
|
|
184
|
+
* dependency is unavailable.
|
|
185
|
+
*
|
|
186
|
+
* @param fontBuffers Font file bytes to parse.
|
|
187
|
+
* @param fontMapping Optional PPTX font name to replacement font mapping.
|
|
188
|
+
* @returns A text measurer, or `null` when setup is not possible.
|
|
102
189
|
*/
|
|
103
190
|
declare function createOpentypeTextMeasurerFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeTextMeasurer | null>;
|
|
191
|
+
/**
|
|
192
|
+
* Font services created from OpenType font data.
|
|
193
|
+
*/
|
|
104
194
|
interface OpentypeSetup {
|
|
195
|
+
/**
|
|
196
|
+
* Measures text width for layout and wrapping.
|
|
197
|
+
*/
|
|
105
198
|
measurer: OpentypeTextMeasurer;
|
|
199
|
+
/**
|
|
200
|
+
* Resolves fonts for converting text to SVG path outlines.
|
|
201
|
+
*/
|
|
106
202
|
fontResolver: TextPathFontResolver;
|
|
107
203
|
}
|
|
108
204
|
/**
|
|
109
|
-
*
|
|
205
|
+
* Create font measurement and SVG path resolution services from font buffers.
|
|
206
|
+
*
|
|
207
|
+
* Use this for advanced integrations that need to provide fonts explicitly
|
|
208
|
+
* instead of relying on system font directories. Returned services can be wired
|
|
209
|
+
* into renderer internals; the public conversion APIs usually only need
|
|
210
|
+
* `fontDirs`, `skipSystemFonts`, and `fontMapping`.
|
|
110
211
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
212
|
+
* @param fontBuffers TTF, OTF, or TTC font file bytes.
|
|
213
|
+
* @param fontMapping Optional PPTX font name to replacement font mapping.
|
|
214
|
+
* @returns Font services, or `null` when no usable font setup can be created.
|
|
113
215
|
*/
|
|
114
216
|
declare function createOpentypeSetupFromBuffers(fontBuffers: FontBuffer[], fontMapping?: FontMapping): Promise<OpentypeSetup | null>;
|
|
115
217
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
218
|
+
* Clear the module-level cache of parsed system fonts.
|
|
219
|
+
*
|
|
220
|
+
* Conversion APIs cache parsed font objects for repeated calls with the same
|
|
221
|
+
* font options. Call this after installing, removing, or replacing fonts in a
|
|
222
|
+
* long-running process when subsequent conversions must reload font files.
|
|
119
223
|
*/
|
|
120
224
|
declare function clearFontCache(): void;
|
|
121
225
|
|
|
122
226
|
/**
|
|
123
|
-
* resvg-wasm
|
|
124
|
-
*
|
|
125
|
-
*
|
|
227
|
+
* Initialize the resvg-wasm module used for PNG conversion.
|
|
228
|
+
*
|
|
229
|
+
* Calling this is optional because `convertPptxToPng` initializes resvg-wasm on
|
|
230
|
+
* first use. Applications may call it during startup to pay the WASM loading
|
|
231
|
+
* cost before handling the first conversion request.
|
|
126
232
|
*/
|
|
127
233
|
declare function initResvgWasm(): Promise<void>;
|
|
128
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Controls how unsupported-feature warnings are collected and printed.
|
|
237
|
+
*
|
|
238
|
+
* `"off"` disables collection, `"warn"` collects entries and prints summaries,
|
|
239
|
+
* and `"debug"` also prints each warning as it is recorded.
|
|
240
|
+
*/
|
|
129
241
|
type LogLevel = "off" | "warn" | "debug";
|
|
242
|
+
/**
|
|
243
|
+
* One unsupported or approximated feature encountered during conversion.
|
|
244
|
+
*/
|
|
130
245
|
interface WarningEntry {
|
|
131
|
-
/**
|
|
246
|
+
/**
|
|
247
|
+
* Stable feature key, for example `"sp.style"` or `"bodyPr@vert"`.
|
|
248
|
+
*/
|
|
132
249
|
feature: string;
|
|
133
|
-
/**
|
|
250
|
+
/**
|
|
251
|
+
* Human-readable warning message.
|
|
252
|
+
*/
|
|
134
253
|
message: string;
|
|
135
|
-
/**
|
|
254
|
+
/**
|
|
255
|
+
* Optional location context, for example `"Slide 1"`.
|
|
256
|
+
*/
|
|
136
257
|
context?: string;
|
|
137
258
|
}
|
|
259
|
+
/**
|
|
260
|
+
* Aggregated warnings from the most recent conversion cycle.
|
|
261
|
+
*/
|
|
138
262
|
interface WarningSummary {
|
|
263
|
+
/**
|
|
264
|
+
* Total number of warning entries.
|
|
265
|
+
*/
|
|
139
266
|
totalCount: number;
|
|
267
|
+
/**
|
|
268
|
+
* Warning counts grouped by feature key.
|
|
269
|
+
*/
|
|
140
270
|
features: {
|
|
141
271
|
feature: string;
|
|
142
272
|
message: string;
|
|
143
273
|
count: number;
|
|
144
274
|
}[];
|
|
145
275
|
}
|
|
276
|
+
/**
|
|
277
|
+
* Return a grouped summary of currently collected warnings.
|
|
278
|
+
*
|
|
279
|
+
* This reads the active warning logger state. The public conversion APIs flush
|
|
280
|
+
* warnings at the end of a conversion so summaries can be printed; after that
|
|
281
|
+
* flush, this returns an empty summary until new warnings are recorded. It is
|
|
282
|
+
* mainly useful for lower-level renderer workflows, tests, and integrations
|
|
283
|
+
* that manage the warning cycle directly.
|
|
284
|
+
*/
|
|
146
285
|
declare function getWarningSummary(): WarningSummary;
|
|
286
|
+
/**
|
|
287
|
+
* Return individual warning entries collected in the current warning cycle.
|
|
288
|
+
*
|
|
289
|
+
* Entries include optional slide or element context when available. The public
|
|
290
|
+
* conversion APIs flush entries at the end of a conversion, so this is mainly
|
|
291
|
+
* useful for lower-level renderer workflows, tests, and integrations that
|
|
292
|
+
* manage the warning cycle directly.
|
|
293
|
+
*/
|
|
147
294
|
declare function getWarningEntries(): readonly WarningEntry[];
|
|
148
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Options shared by PPTX-to-SVG and PPTX-to-PNG conversion.
|
|
298
|
+
*/
|
|
149
299
|
interface ConvertOptions {
|
|
150
|
-
/**
|
|
300
|
+
/**
|
|
301
|
+
* Target slide numbers to convert, using PowerPoint-style 1-based numbering.
|
|
302
|
+
*
|
|
303
|
+
* When omitted, every slide in the presentation is converted. Missing or
|
|
304
|
+
* out-of-range slide numbers produce no output for those entries.
|
|
305
|
+
*/
|
|
151
306
|
slides?: number[];
|
|
152
|
-
/**
|
|
307
|
+
/**
|
|
308
|
+
* Output width in pixels.
|
|
309
|
+
*
|
|
310
|
+
* PNG output rasterizes to this width while preserving the slide aspect
|
|
311
|
+
* ratio. Defaults to 960. SVG output keeps the slide's native pixel size from
|
|
312
|
+
* the PPTX slide dimensions and does not use this option.
|
|
313
|
+
*/
|
|
153
314
|
width?: number;
|
|
154
|
-
/**
|
|
315
|
+
/**
|
|
316
|
+
* Output height in pixels.
|
|
317
|
+
*
|
|
318
|
+
* PNG rasterization currently always uses `width`, either the provided value
|
|
319
|
+
* or the default width, so this option is ignored by the public conversion
|
|
320
|
+
* APIs. SVG output keeps the slide's native pixel size and does not use this
|
|
321
|
+
* option.
|
|
322
|
+
*/
|
|
155
323
|
height?: number;
|
|
156
|
-
/**
|
|
324
|
+
/**
|
|
325
|
+
* Warning log level for unsupported or approximated PPTX features.
|
|
326
|
+
*
|
|
327
|
+
* Defaults to `"off"`. Diagnostics are always collected in the conversion
|
|
328
|
+
* report; this option only controls console output. Use `"warn"` to print
|
|
329
|
+
* summaries, or `"debug"` to print individual warning entries as they are
|
|
330
|
+
* recorded.
|
|
331
|
+
*/
|
|
157
332
|
logLevel?: LogLevel;
|
|
158
|
-
/**
|
|
333
|
+
/**
|
|
334
|
+
* Additional directories that are scanned for font files.
|
|
335
|
+
*
|
|
336
|
+
* These directories are searched in addition to system font directories unless
|
|
337
|
+
* `skipSystemFonts` is true.
|
|
338
|
+
*/
|
|
159
339
|
fontDirs?: string[];
|
|
160
|
-
/**
|
|
340
|
+
/**
|
|
341
|
+
* Custom PPTX font name to replacement font name mapping.
|
|
342
|
+
*
|
|
343
|
+
* Entries are merged with `DEFAULT_FONT_MAPPING`; user-provided entries take
|
|
344
|
+
* precedence. This is useful when a PPTX references proprietary or corporate
|
|
345
|
+
* fonts that should render with installed alternatives.
|
|
346
|
+
*/
|
|
161
347
|
fontMapping?: FontMapping;
|
|
162
|
-
/**
|
|
348
|
+
/**
|
|
349
|
+
* Skip OS system font directories and only scan `fontDirs`.
|
|
350
|
+
*
|
|
351
|
+
* This is useful in containers or serverless environments where bundled fonts
|
|
352
|
+
* should be the only fonts used.
|
|
353
|
+
*/
|
|
163
354
|
skipSystemFonts?: boolean;
|
|
164
355
|
/**
|
|
165
|
-
* SVG
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
356
|
+
* Text output mode for SVG conversion.
|
|
357
|
+
*
|
|
358
|
+
* Defaults to `"path"`, which emits glyph outlines as `<path>` elements and
|
|
359
|
+
* does not require fonts in the SVG viewing environment. `"text"` emits native
|
|
360
|
+
* `<text>` elements with subset-font `@font-face` data URIs, enabling browser
|
|
361
|
+
* text selection and native text rendering for inline SVG.
|
|
362
|
+
*
|
|
363
|
+
* Embedded fonts and native text may not render as expected when the SVG is
|
|
364
|
+
* loaded through `<img src="...svg">` or sanitized. `convertPptxToPng` ignores
|
|
365
|
+
* this option and always renders with `"path"` output because resvg does not
|
|
366
|
+
* interpret the embedded `@font-face` rules used by SVG text output.
|
|
171
367
|
*/
|
|
172
368
|
textOutput?: "path" | "text";
|
|
173
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* SVG conversion result for one slide.
|
|
372
|
+
*/
|
|
174
373
|
interface SlideSvg {
|
|
374
|
+
/**
|
|
375
|
+
* Original slide number in the PPTX file, using 1-based numbering.
|
|
376
|
+
*/
|
|
175
377
|
slideNumber: number;
|
|
378
|
+
/**
|
|
379
|
+
* Complete SVG document string for the slide.
|
|
380
|
+
*/
|
|
176
381
|
svg: string;
|
|
177
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* PNG conversion result for one slide.
|
|
385
|
+
*/
|
|
178
386
|
interface SlideImage {
|
|
387
|
+
/**
|
|
388
|
+
* Original slide number in the PPTX file, using 1-based numbering.
|
|
389
|
+
*/
|
|
179
390
|
slideNumber: number;
|
|
391
|
+
/**
|
|
392
|
+
* PNG image bytes for the rendered slide.
|
|
393
|
+
*/
|
|
180
394
|
png: Buffer;
|
|
395
|
+
/**
|
|
396
|
+
* Actual output image width in pixels after rasterization.
|
|
397
|
+
*/
|
|
181
398
|
width: number;
|
|
399
|
+
/**
|
|
400
|
+
* Actual output image height in pixels after rasterization.
|
|
401
|
+
*/
|
|
182
402
|
height: number;
|
|
183
403
|
}
|
|
184
|
-
|
|
185
|
-
|
|
404
|
+
interface ConversionDiagnostic {
|
|
405
|
+
readonly source: "document" | "computed-view" | "renderer-adapter" | "renderer";
|
|
406
|
+
readonly severity: "info" | "warning" | "error";
|
|
407
|
+
readonly code: string;
|
|
408
|
+
readonly message: string;
|
|
409
|
+
readonly slideNumber?: number;
|
|
410
|
+
readonly sourcePartPath?: string;
|
|
411
|
+
readonly context?: string;
|
|
412
|
+
readonly handle?: SourceHandle;
|
|
413
|
+
}
|
|
414
|
+
interface SupportCoverageCounts {
|
|
415
|
+
/**
|
|
416
|
+
* Number of PPTX source/computed elements considered for rendering.
|
|
417
|
+
*/
|
|
418
|
+
readonly inputElements: number;
|
|
419
|
+
/**
|
|
420
|
+
* Number of renderer-model elements produced for SVG / PNG output.
|
|
421
|
+
*/
|
|
422
|
+
readonly outputElements: number;
|
|
423
|
+
/**
|
|
424
|
+
* Elements or raw nodes skipped because they are outside the supported render subset.
|
|
425
|
+
*/
|
|
426
|
+
readonly skippedElements: number;
|
|
427
|
+
/**
|
|
428
|
+
* Elements skipped because a referenced PPTX part or relationship could not be resolved.
|
|
429
|
+
*/
|
|
430
|
+
readonly unresolvedElements: number;
|
|
431
|
+
/**
|
|
432
|
+
* Elements or properties rendered with a fallback or ignored unsupported property.
|
|
433
|
+
*/
|
|
434
|
+
readonly fallbackElements: number;
|
|
435
|
+
/**
|
|
436
|
+
* Diagnostics with warning severity that affect support/renderability confidence.
|
|
437
|
+
*/
|
|
438
|
+
readonly warnings: number;
|
|
439
|
+
}
|
|
440
|
+
interface SlideSupportCoverage extends SupportCoverageCounts {
|
|
441
|
+
readonly slideNumber: number;
|
|
442
|
+
}
|
|
443
|
+
interface SupportCoverage {
|
|
444
|
+
/**
|
|
445
|
+
* Support/renderability coverage summary. This is not a visual-match or pixel accuracy metric.
|
|
446
|
+
*/
|
|
447
|
+
readonly overall: SupportCoverageCounts;
|
|
448
|
+
readonly slides: readonly SlideSupportCoverage[];
|
|
449
|
+
}
|
|
450
|
+
interface SvgConversionReport {
|
|
451
|
+
readonly slides: readonly SlideSvg[];
|
|
452
|
+
readonly diagnostics: readonly ConversionDiagnostic[];
|
|
453
|
+
readonly supportCoverage: SupportCoverage;
|
|
454
|
+
}
|
|
455
|
+
interface PngConversionReport {
|
|
456
|
+
readonly slides: readonly SlideImage[];
|
|
457
|
+
readonly diagnostics: readonly ConversionDiagnostic[];
|
|
458
|
+
readonly supportCoverage: SupportCoverage;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Convert a PPTX file to SVG documents.
|
|
462
|
+
*
|
|
463
|
+
* @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
|
|
464
|
+
* @param options Conversion options. `slides` uses 1-based slide numbers; when
|
|
465
|
+
* omitted, all slides are converted.
|
|
466
|
+
* @returns A conversion report containing converted slides, diagnostics, and support coverage.
|
|
467
|
+
*
|
|
468
|
+
* Text is emitted as SVG paths by default for portable rendering. Set
|
|
469
|
+
* `textOutput: "text"` to emit native `<text>` elements with embedded subset
|
|
470
|
+
* fonts for inline browser SVG use. Font directories and font mapping options
|
|
471
|
+
* control how PPTX font names are resolved for text measurement and text output.
|
|
472
|
+
*/
|
|
473
|
+
declare function convertPptxToSvg(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<SvgConversionReport>;
|
|
474
|
+
/**
|
|
475
|
+
* Convert a PPTX file to PNG images.
|
|
476
|
+
*
|
|
477
|
+
* @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
|
|
478
|
+
* @param options Conversion options. `slides` uses 1-based slide numbers; when
|
|
479
|
+
* omitted, all slides are converted.
|
|
480
|
+
* @returns A conversion report containing converted PNG slides, diagnostics, and support coverage.
|
|
481
|
+
*
|
|
482
|
+
* PNG conversion first renders each slide to SVG and then rasterizes it with
|
|
483
|
+
* resvg. The `textOutput` option is intentionally ignored: PNG rendering always
|
|
484
|
+
* uses path-based text output because resvg does not interpret the embedded
|
|
485
|
+
* `@font-face` rules used by SVG text mode. Font directories and font mapping
|
|
486
|
+
* options are still used to resolve glyph outlines and text metrics.
|
|
487
|
+
*/
|
|
488
|
+
declare function convertPptxToPng(input: Buffer | Uint8Array, options?: ConvertOptions): Promise<PngConversionReport>;
|
|
186
489
|
|
|
187
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* Font names discovered in a PPTX file.
|
|
492
|
+
*/
|
|
188
493
|
interface UsedFonts {
|
|
189
|
-
/**
|
|
494
|
+
/**
|
|
495
|
+
* Theme font slots resolved from the presentation's default theme.
|
|
496
|
+
*/
|
|
190
497
|
theme: {
|
|
498
|
+
/**
|
|
499
|
+
* Major Latin theme font.
|
|
500
|
+
*/
|
|
191
501
|
majorFont: string;
|
|
502
|
+
/**
|
|
503
|
+
* Minor Latin theme font.
|
|
504
|
+
*/
|
|
192
505
|
minorFont: string;
|
|
506
|
+
/**
|
|
507
|
+
* Major East Asian theme font, when present.
|
|
508
|
+
*/
|
|
193
509
|
majorFontEa: string | null;
|
|
510
|
+
/**
|
|
511
|
+
* Minor East Asian theme font, when present.
|
|
512
|
+
*/
|
|
194
513
|
minorFontEa: string | null;
|
|
514
|
+
/**
|
|
515
|
+
* Major complex-script theme font, when present.
|
|
516
|
+
*/
|
|
195
517
|
majorFontCs: string | null;
|
|
518
|
+
/**
|
|
519
|
+
* Minor complex-script theme font, when present.
|
|
520
|
+
*/
|
|
196
521
|
minorFontCs: string | null;
|
|
197
522
|
};
|
|
198
|
-
/**
|
|
523
|
+
/**
|
|
524
|
+
* Unique sorted font names used by text runs, bullets, and theme font slots.
|
|
525
|
+
*/
|
|
199
526
|
fonts: string[];
|
|
200
527
|
}
|
|
201
528
|
/**
|
|
202
|
-
* PPTX
|
|
203
|
-
*
|
|
529
|
+
* Parse a PPTX file and collect the font names it references.
|
|
530
|
+
*
|
|
531
|
+
* This is a lightweight preflight helper: it reads the document model and text
|
|
532
|
+
* styles but does not render slides or load font files. Use it to decide which
|
|
533
|
+
* fonts should be installed, bundled, or mapped before calling the conversion
|
|
534
|
+
* APIs.
|
|
535
|
+
*
|
|
536
|
+
* @param input PPTX binary data as a Node.js `Buffer` or `Uint8Array`.
|
|
537
|
+
* @returns Theme font slots and a unique sorted list of referenced font names.
|
|
204
538
|
*/
|
|
205
539
|
declare function collectUsedFonts(input: Buffer | Uint8Array): UsedFonts;
|
|
206
540
|
|
|
207
|
-
export { type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type SlideImage, type SlideSvg, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
|
|
541
|
+
export { type ConversionDiagnostic, type ConvertOptions, DEFAULT_FONT_MAPPING, type FontBuffer, type FontMapping, type LogLevel, type OpentypeSetup, type PngConversionReport, type SlideImage, type SlideSupportCoverage, type SlideSvg, type SupportCoverage, type SupportCoverageCounts, type SvgConversionReport, type UsedFonts, type WarningEntry, type WarningSummary, clearFontCache, collectUsedFonts, convertPptxToPng, convertPptxToSvg, createFontMapping, createOpentypeSetupFromBuffers, createOpentypeTextMeasurerFromBuffers, getMappedFont, getWarningEntries, getWarningSummary, initResvgWasm };
|