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