@office-kit/pptx-preview 0.14.0 → 1.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/README.md CHANGED
@@ -6,7 +6,7 @@ it to a **PNG / RGBA image in Node — with no headless browser**.
6
6
 
7
7
  > **Experimental (0.x).** This package lives in the `@office-kit/pptx` monorepo and
8
8
  > also powers the docs-site playground and the fidelity harness. The renderer
9
- > is an _approximation_ of PowerPoint / LibreOffice output and is still
9
+ > is an _approximation_ of desktop presentation app / LibreOffice output and is still
10
10
  > evolving; the API may change between minor versions, and `0.x` semver applies
11
11
  > (a minor bump may break). See [fidelity](#fidelity) below.
12
12
 
@@ -42,6 +42,12 @@ const svg = renderSlideToSvg(pres, getSlides(pres)[0]);
42
42
  // → '<svg …>…</svg>' (text laid out via <foreignObject> — the browser wraps it)
43
43
  ```
44
44
 
45
+ `renderSlideLayoutToSvg(pres, layout, { master })` draws what a slide master
46
+ editor shows behind the placeholders: the layout's background and decorative
47
+ shapes over its master's (the master's are left out when the layout hides
48
+ background graphics), or with `master: true` the slide master's own background
49
+ and shapes. Placeholders are not drawn.
50
+
45
51
  ### Underlines in custom HTML editors
46
52
 
47
53
  `textUnderlineStyle(underline, color)` returns inline CSS for a DrawingML
@@ -119,22 +125,25 @@ Options:
119
125
  wrapping is normal for body text; turn it on when auditing titles or labels
120
126
  meant to stay on one line.
121
127
 
122
- Accuracy: the bundled fonts are metric-compatible with the Office defaults, so
128
+ Accuracy: the bundled fonts are metric-compatible with the common default fonts, so
123
129
  verdicts for Calibri / Cambria / Arial / Times / Courier decks match real glyph
124
130
  widths; for any other font (custom brand fonts, Japanese fonts), register the
125
131
  real files via `buildFontkitMeasurer({ fonts })` — a registered font is used
126
132
  both for runs that name it and as a glyph fallback for CJK text in runs that
127
- resolve to a Latin face. Line-break positions can differ from PowerPoint by a
133
+ resolve to a Latin face. Line-break positions can differ from the reference desktop app by a
128
134
  few characters in edge cases (kinsoku, hyphenation), which is what the default
129
135
  1 px tolerance absorbs. Table cell text is not audited yet.
130
136
 
131
137
  ## Fidelity
132
138
 
133
- This is a high-fidelity preview, not a spec-complete PowerPoint renderer.
139
+ This is a high-fidelity preview, not a spec-complete presentation renderer.
134
140
  Preset and custom geometry, solid/gradient/pattern/image fills (including the
135
141
  placeholder layout/master cascade), strokes, rotation, effects (shadow, glow,
136
142
  soft edge, reflection), images with adjustments, charts (column, bar, line,
137
- area, pie, doughnut, scatter, radar, bubble), tables with per-run cell text,
143
+ area, pie, doughnut, scatter, radar, bubble), tables with per-run cell text and
144
+ every part of their table style (the 74 built-in table styles included:
145
+ fills, translucent bands, borders, text, the Themed Styles' background, and
146
+ the six style options; the background's shadow is not drawn),
138
147
  vertical and multi-column text in both text-layout modes, picture bullets, and
139
148
  template (layout/master) decoration all render. EMF pictures containing solid-filled
140
149
  line/Bézier paths, including rectangular and path clipping with copy semantics,
@@ -1,4 +1,4 @@
1
- import { BulletStyle, PresentationData, SlideData, SlideShapeData, TextFormat, getParagraphBullet, getParagraphIndent, getParagraphPropertiesEffective, getShapeBodyPrEffective, getShapeTextAutoFitParams, getShapeTextColumns, getShapeTextDirection } from "@office-kit/pptx";
1
+ import { BulletStyle, PresentationData, SlideData, SlideLayoutData, SlideShapeData, TextFormat, getParagraphBullet, getParagraphIndent, getParagraphPropertiesEffective, getShapeBodyPrEffective, getShapeTextAutoFitParams, getShapeTextColumns, getShapeTextDirection } from "@office-kit/pptx";
2
2
 
3
3
  //#region src/text-layout.d.ts
4
4
  /** What a measurer needs to size one run. Pixels at 96 DPI; the caller has
@@ -42,6 +42,9 @@ interface RenderSlideOptions {
42
42
  * Bodies with custom tab stops use SVG positioning in either mode, since
43
43
  * CSS cannot represent their alignment. The harness opts into 'svg'. */
44
44
  readonly textLayout?: TextLayoutMode;
45
+ /** `false` paints only the slide's own shapes on a transparent surface:
46
+ * no background fill and no master or layout graphics. Defaults to `true`. */
47
+ readonly background?: boolean;
45
48
  }
46
49
  declare const SANS = "Carlito";
47
50
  declare const SERIF = "Caladea";
@@ -69,6 +72,17 @@ declare const renderTextEffectsSvg: (pres: PresentationData, slide: SlideData, s
69
72
  };
70
73
  }) => string;
71
74
  declare const renderSlideSvg: (pres: PresentationData, slide: SlideData, opts?: RenderSlideOptions) => string;
75
+ /**
76
+ * Draws a slide layout — or, with `master`, its slide master — the way
77
+ * the reference desktop app's Slide Master view shows it behind the placeholders: the
78
+ * background and the decorative (non-placeholder) shapes of the master and,
79
+ * for a layout, of the layout itself. A layout that hides background graphics
80
+ * leaves the master's shapes out. Placeholders are not drawn; an editor draws
81
+ * them with their prompt text over this.
82
+ */
83
+ declare const renderSlideLayoutSvg: (pres: PresentationData, layout: SlideLayoutData, opts?: RenderSlideOptions & {
84
+ readonly master?: boolean;
85
+ }) => string;
72
86
  //#endregion
73
87
  //#region src/audit.d.ts
74
88
  interface IssueBase {
@@ -96,7 +110,7 @@ interface AuditTextLayoutOptions {
96
110
  * `@office-kit/pptx-preview/node` for real glyph metrics. */
97
111
  readonly measureText?: TextMeasurer;
98
112
  /** Overflow at or below this many px (96 DPI) is ignored. Default 1 —
99
- * measurement and PowerPoint disagree by sub-pixel amounts routinely. */
113
+ * measurement and the reference desktop app disagree by sub-pixel amounts routinely. */
100
114
  readonly tolerancePx?: number;
101
115
  /** Also report paragraphs that wrap onto more lines than their explicit
102
116
  * breaks author (段落ち). Off by default: wrapping is normal for body
@@ -120,6 +134,16 @@ declare const paragraphNumberLabels: (paraData: ReadonlyArray<{
120
134
  level: number;
121
135
  }>) => Array<string | null>;
122
136
  //#endregion
137
+ //#region src/decimal-separator.d.ts
138
+ /**
139
+ * The character a decimal tab stop aligns on for a run's language
140
+ * (`<a:rPr lang>`): `,` for `de-DE`, `.` for `en-US`. Runs without a
141
+ * language, or with one Intl does not know, align on `.`. The reference desktop app on Mac
142
+ * uses the run language too, not the UI or system locale (native capture
143
+ * 2026-10-07: Set Proofing Language to German moved alignment to `,`).
144
+ */
145
+ declare function decimalSeparatorOf(lang: string | null | undefined): string;
146
+ //#endregion
123
147
  //#region src/text-body-rect.d.ts
124
148
  /** A text rectangle as fractions of the shape's extent. */
125
149
  interface TextRectFractions {
@@ -145,7 +169,7 @@ declare function shapeTextRect(shape: SlideShapeData): TextRectFractions | null;
145
169
  * {@link shapeTextRect}, or `null` for the whole box) placed in `bounds`, less
146
170
  * the body insets. All coordinates and margins must use the same unit
147
171
  * (normally EMU). When margins collapse a region, the region is kept without
148
- * them, as PowerPoint does.
172
+ * them, as the reference desktop app does.
149
173
  */
150
174
  declare function resolveTextBodyRect(bounds: {
151
175
  x: number;
@@ -175,8 +199,8 @@ interface VerticalTextStyle {
175
199
  }
176
200
  /**
177
201
  * `<a:bodyPr vert="…"/>` as CSS. `writing-mode` is the right primitive for
178
- * the East-Asian and Mongolian cases, and `text-orientation` for the WordArt
179
- * ones, which stack upright glyphs. `vert270` reads bottom-to-top, which no
202
+ * the East-Asian and Mongolian cases, and `text-orientation` for the
203
+ * `wordArtVert` ones, which stack upright glyphs. `vert270` reads bottom-to-top, which no
180
204
  * writing-mode expresses on its own — hence the half turn. Its columns still
181
205
  * follow the OOXML vertical-rl progression before that half turn; using
182
206
  * vertical-lr here reverses the column order relative to the SVG renderer.
@@ -212,7 +236,7 @@ interface ShapeAutoFitScaleOptions {
212
236
  *
213
237
  * `1` for a shape with no `<a:normAutofit>`: `<a:noAutofit>` overflows and
214
238
  * `<a:spAutoFit>` grows the box instead, so neither shrinks the text. A shape
215
- * with a baked `fontScale` reports that, unchanged — it is what PowerPoint
239
+ * with a baked `fontScale` reports that, unchanged — it is what the reference desktop app
216
240
  * itself applied.
217
241
  */
218
242
  declare function shapeAutoFitScale(pres: PresentationData, shape: SlideShapeData, options?: ShapeAutoFitScaleOptions): number;
@@ -232,5 +256,5 @@ declare function shapeTextAnchorOffset(pres: PresentationData, shape: SlideShape
232
256
  */
233
257
  declare function textUnderlineStyle(underline: TextFormat['underline'], color: string, includeDecorationColor?: boolean): string;
234
258
  //#endregion
235
- export { SERIF as C, defaultMeasurer as D, TextMeasurer as E, substituteFamily as O, SANS as S, TextLayoutMode as T, ARIAL as _, VerticalTextStyle as a, MeasureResult as b, TextRectFractions as c, paragraphNumberLabels as d, AuditTextLayoutOptions as f, renderTextEffectsSvg as g, renderSlideSvg as h, shapeTextAnchorOffset as i, resolveTextBodyRect as l, auditTextLayout as m, ShapeAutoFitScaleOptions as n, textColumnsStyle as o, TextAuditIssue as p, shapeAutoFitScale as r, verticalTextStyle as s, textUnderlineStyle as t, shapeTextRect as u, FontSpec as v, TIMES as w, RenderSlideOptions as x, MONO as y };
236
- //# sourceMappingURL=index-DUFPGYOf.d.ts.map
259
+ export { substituteFamily as A, RenderSlideOptions as C, TextLayoutMode as D, TIMES as E, TextMeasurer as O, MeasureResult as S, SERIF as T, renderSlideSvg as _, VerticalTextStyle as a, FontSpec as b, TextRectFractions as c, decimalSeparatorOf as d, paragraphNumberLabels as f, renderSlideLayoutSvg as g, auditTextLayout as h, shapeTextAnchorOffset as i, defaultMeasurer as k, resolveTextBodyRect as l, TextAuditIssue as m, ShapeAutoFitScaleOptions as n, textColumnsStyle as o, AuditTextLayoutOptions as p, shapeAutoFitScale as r, verticalTextStyle as s, textUnderlineStyle as t, shapeTextRect as u, renderTextEffectsSvg as v, SANS as w, MONO as x, ARIAL as y };
260
+ //# sourceMappingURL=index-74n14k3Y.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { C as SERIF, D as defaultMeasurer, E as TextMeasurer, O as substituteFamily, S as SANS, T as TextLayoutMode, _ as ARIAL, a as VerticalTextStyle, b as MeasureResult, c as TextRectFractions, d as paragraphNumberLabels, f as AuditTextLayoutOptions, g as renderTextEffectsSvg, h as renderSlideSvg, i as shapeTextAnchorOffset, l as resolveTextBodyRect, m as auditTextLayout, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as TextAuditIssue, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as FontSpec, w as TIMES, x as RenderSlideOptions, y as MONO } from "./index-DUFPGYOf.js";
2
- export { ARIAL, type AuditTextLayoutOptions, type FontSpec, MONO, type MeasureResult, type RenderSlideOptions, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
1
+ import { A as substituteFamily, C as RenderSlideOptions, D as TextLayoutMode, E as TIMES, O as TextMeasurer, S as MeasureResult, T as SERIF, _ as renderSlideSvg, a as VerticalTextStyle, b as FontSpec, c as TextRectFractions, d as decimalSeparatorOf, f as paragraphNumberLabels, g as renderSlideLayoutSvg, h as auditTextLayout, i as shapeTextAnchorOffset, k as defaultMeasurer, l as resolveTextBodyRect, m as TextAuditIssue, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as AuditTextLayoutOptions, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as renderTextEffectsSvg, w as SANS, x as MONO, y as ARIAL } from "./index-74n14k3Y.js";
2
+ export { ARIAL, type AuditTextLayoutOptions, type FontSpec, MONO, type MeasureResult, type RenderSlideOptions, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, decimalSeparatorOf, defaultMeasurer, paragraphNumberLabels, renderSlideLayoutSvg as renderSlideLayoutToSvg, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as shapeTextRect, c as MONO, d as TIMES, f as defaultMeasurer, g as textUnderlineStyle, h as paragraphNumberLabels, i as renderSlideSvg, l as SANS, m as substituteFamily, n as shapeTextAnchorOffset, o as ARIAL, r as auditTextLayout, t as shapeAutoFitScale, u as SERIF, v as verticalTextStyle, y as resolveTextBodyRect } from "./src-Bwmf324Z.js";
2
- export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, defaultMeasurer, paragraphNumberLabels, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
1
+ import { S as shapeTextRect, _ as paragraphNumberLabels, a as renderSlideSvg, b as verticalTextStyle, d as SERIF, f as TIMES, g as decimalSeparatorOf, h as substituteFamily, i as renderSlideLayoutSvg, l as MONO, n as shapeTextAnchorOffset, o as renderTextEffectsSvg, p as defaultMeasurer, r as auditTextLayout, s as ARIAL, t as shapeAutoFitScale, u as SANS, v as textUnderlineStyle, x as resolveTextBodyRect, y as textColumnsStyle } from "./src-pb3C61GD.js";
2
+ export { ARIAL, MONO, SANS, SERIF, TIMES, auditTextLayout, decimalSeparatorOf, defaultMeasurer, paragraphNumberLabels, renderSlideLayoutSvg as renderSlideLayoutToSvg, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
package/dist/node.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as SERIF, D as defaultMeasurer, E as TextMeasurer, O as substituteFamily, S as SANS, T as TextLayoutMode, _ as ARIAL, a as VerticalTextStyle, b as MeasureResult, c as TextRectFractions, d as paragraphNumberLabels, f as AuditTextLayoutOptions, g as renderTextEffectsSvg, h as renderSlideSvg, i as shapeTextAnchorOffset, l as resolveTextBodyRect, m as auditTextLayout, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as TextAuditIssue, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as FontSpec, w as TIMES, x as RenderSlideOptions, y as MONO } from "./index-DUFPGYOf.js";
1
+ import { A as substituteFamily, C as RenderSlideOptions, D as TextLayoutMode, E as TIMES, O as TextMeasurer, S as MeasureResult, T as SERIF, _ as renderSlideSvg, a as VerticalTextStyle, b as FontSpec, c as TextRectFractions, d as decimalSeparatorOf, f as paragraphNumberLabels, g as renderSlideLayoutSvg, h as auditTextLayout, i as shapeTextAnchorOffset, k as defaultMeasurer, l as resolveTextBodyRect, m as TextAuditIssue, n as ShapeAutoFitScaleOptions, o as textColumnsStyle, p as AuditTextLayoutOptions, r as shapeAutoFitScale, s as verticalTextStyle, t as textUnderlineStyle, u as shapeTextRect, v as renderTextEffectsSvg, w as SANS, x as MONO, y as ARIAL } from "./index-74n14k3Y.js";
2
2
  import { PresentationData, SlideData } from "@office-kit/pptx";
3
3
 
4
4
  //#region src/measure.d.ts
@@ -73,5 +73,5 @@ declare const renderSlideToRgba: (pres: PresentationData, slide: SlideData, opts
73
73
  readonly png: Uint8Array;
74
74
  };
75
75
  //#endregion
76
- export { ARIAL, type AuditTextLayoutOptions, FONT_DIR, FONT_FILES, type FontSpec, type FontkitMeasurerOptions, MONO, type MeasureResult, type RegisteredFont, RenderImageOptions, type RenderSlideOptions, RgbaImage, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
76
+ export { ARIAL, type AuditTextLayoutOptions, FONT_DIR, FONT_FILES, type FontSpec, type FontkitMeasurerOptions, MONO, type MeasureResult, type RegisteredFont, RenderImageOptions, type RenderSlideOptions, RgbaImage, SANS, SERIF, type ShapeAutoFitScaleOptions, TIMES, type TextAuditIssue, type TextLayoutMode, type TextMeasurer, type TextRectFractions, type VerticalTextStyle, auditTextLayout, buildFontkitMeasurer, decimalSeparatorOf, defaultMeasurer, paragraphNumberLabels, renderSlideLayoutSvg as renderSlideLayoutToSvg, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
77
77
  //# sourceMappingURL=node.d.ts.map
package/dist/node.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as textColumnsStyle, a as renderTextEffectsSvg, b as shapeTextRect, c as MONO, d as TIMES, f as defaultMeasurer, g as textUnderlineStyle, h as paragraphNumberLabels, i as renderSlideSvg, l as SANS, m as substituteFamily, n as shapeTextAnchorOffset, o as ARIAL, p as isCjk, r as auditTextLayout, s as AVG_GLYPH_W_RATIO, t as shapeAutoFitScale, u as SERIF, v as verticalTextStyle, y as resolveTextBodyRect } from "./src-Bwmf324Z.js";
1
+ import { S as shapeTextRect, _ as paragraphNumberLabels, a as renderSlideSvg, b as verticalTextStyle, c as AVG_GLYPH_W_RATIO, d as SERIF, f as TIMES, g as decimalSeparatorOf, h as substituteFamily, i as renderSlideLayoutSvg, l as MONO, m as isCjk, n as shapeTextAnchorOffset, o as renderTextEffectsSvg, p as defaultMeasurer, r as auditTextLayout, s as ARIAL, t as shapeAutoFitScale, u as SANS, v as textUnderlineStyle, x as resolveTextBodyRect, y as textColumnsStyle } from "./src-pb3C61GD.js";
2
2
  import { getSlideSize } from "@office-kit/pptx";
3
3
  import { Resvg } from "@resvg/resvg-js";
4
4
  import * as fontkit from "fontkit";
@@ -195,6 +195,6 @@ const renderSlideToRgba = (pres, slide, opts = {}) => {
195
195
  };
196
196
  };
197
197
  //#endregion
198
- export { ARIAL, FONT_DIR, FONT_FILES, MONO, SANS, SERIF, TIMES, auditTextLayout, buildFontkitMeasurer, defaultMeasurer, paragraphNumberLabels, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
198
+ export { ARIAL, FONT_DIR, FONT_FILES, MONO, SANS, SERIF, TIMES, auditTextLayout, buildFontkitMeasurer, decimalSeparatorOf, defaultMeasurer, paragraphNumberLabels, renderSlideLayoutSvg as renderSlideLayoutToSvg, renderSlideToImage, renderSlideToRgba, renderSlideSvg as renderSlideToSvg, renderTextEffectsSvg, resolveTextBodyRect, shapeAutoFitScale, shapeTextAnchorOffset, shapeTextRect, substituteFamily, textColumnsStyle, textUnderlineStyle, verticalTextStyle };
199
199
 
200
200
  //# sourceMappingURL=node.js.map