Skip to Content

Function: convertPptxToPng()

function convertPptxToPng(input: Uint8Array, options?: ConvertOptions): Promise<PngConversionReport>;

Convert a PPTX file to PNG images.

Parameters

input

Uint8Array

PPTX binary data.

options?

ConvertOptions

Conversion options. slides uses 1-based slide numbers; when omitted, all slides are converted.

ConvertOptions

The options accepted by this function are expanded here from ConvertOptions.

fontDirs?

optional fontDirs?: string[];

Additional directories that are scanned for font files.

These directories are searched in addition to system font directories unless skipSystemFonts is true. This option uses Node.js filesystem APIs; use fonts when rendering in browsers, Edge Runtime, or other environments where filesystem access is unavailable. It applies to Node.js SVG and PNG conversion and is ignored by browser conversion.

Default Value

No additional font directories.

fontMapping?

optional fontMapping?: FontMapping;

Custom PPTX font name to replacement font name mapping.

Entries are merged with DEFAULT_FONT_MAPPING; user-provided entries take precedence. This is useful when a PPTX references proprietary or corporate fonts that should render with installed alternatives. It applies to SVG and PNG conversion in Node.js and browsers.

Default Value

DEFAULT_FONT_MAPPING.


fonts?

optional fonts?: FontBuffer[];

Font file bytes supplied directly by the caller.

Use this browser-safe option when fonts are fetched from a URL, bundled by an application, or otherwise loaded without Node.js filesystem APIs. When provided, these font buffers are used instead of system font scanning. It applies to SVG and PNG conversion in Node.js and browsers.

Default Value

No caller-provided font buffers.

height?

optional height?: number;

Output height in pixels.

PNG rasterization currently always uses width, either the provided value or the default width, so this option is ignored by the public conversion APIs. SVG output keeps the slide’s native pixel size and does not use this option. It therefore has no effective default in either runtime.


logLevel?

optional logLevel?: LogLevel;

Warning log level for unsupported or approximated PPTX features.

Defaults to "off". Diagnostics are always collected in the conversion report; this option only controls console output. Use "warn" to print summaries, or "debug" to print individual warning entries as they are recorded. It applies to SVG and PNG conversion in Node.js and browsers.

Default Value

"off"


skipSystemFonts?

optional skipSystemFonts?: boolean;

Skip OS system font directories and only scan fontDirs.

This is useful in containers or serverless environments where bundled fonts should be the only fonts used.

Node.js SVG and PNG conversion support both values. Browser conversion does not scan the filesystem, so this option has no effect there and browser callers should use fonts instead.

Default Value

false

slides?

optional slides?: number[];

Target slide numbers to convert, using PowerPoint-style 1-based numbering.

When omitted, every slide in the presentation is converted. Missing or out-of-range slide numbers produce no output for those entries. This option applies to SVG and PNG conversion in Node.js and browsers.

Default Value

All presentation slides.

textOutput?

optional textOutput?: "text" | "path";

Text output mode for SVG conversion.

Defaults to "path", which emits glyph outlines as <path> elements and does not require fonts in the SVG viewing environment. "text" emits native <text> elements with subset-font @font-face data URIs, enabling browser text selection and native text rendering for inline SVG.

Embedded fonts and native text may not render as expected when the SVG is loaded through <img src="...svg"> or sanitized. convertPptxToPng ignores this option and requests "path" output because resvg does not interpret the embedded @font-face rules used by SVG text output. If a requested font cannot be resolved, that text can still fall back to native SVG text. The behavior is the same in Node.js and browsers.

Default Value

"path"


width?

optional width?: number;

Output width in pixels.

PNG output rasterizes to this width while preserving the slide aspect ratio. Defaults to 960. SVG output keeps the slide’s native pixel size from the PPTX slide dimensions and does not use this option. The PNG behavior is the same in Node.js and browsers.

Default Value

960 for PNG conversion; ignored for SVG conversion.

Returns

Promise<PngConversionReport>

A conversion report containing converted PNG slides, diagnostics, and support coverage.

PNG conversion first renders each slide to SVG and then rasterizes it with resvg. The textOutput option is intentionally ignored: PNG rendering always uses path-based text output because resvg does not interpret the embedded @font-face rules used by SVG text mode. Font directories and font mapping options are still used to resolve glyph outlines and text metrics.