Skip to content

Export Images in Editor Mode

Try it online

Switch between view, contain, and size, adjust parameters in real time, and preview multiple exported slides.

Open the slide image export example →

Editor mode exports PNG, JPG, or SVG images through editor.slides.exportImage(options). Starting with 2.10.0, image export uses three mutually exclusive modes: view, contain, and size.

To export LaTeX/TikZ source, do not use exportImage(). Call editor.slides.exportLatex() instead.

Choosing a mode

GoalModeWhat determines the output size
Export an exact world-coordinate viewportviewviewBounds, camera scale, and pixelRatio
Include all visible content without fixing the final sizecontainVisual content bounds, file camera scale, pixelRatio, and padding
Produce an image with exact pixel dimensionssizeThe specified width and height
  • Use view when you know the world-coordinate region to capture.
  • Use contain when all content must remain visible and the image may follow the content size.
  • Use size when an API, layout, or thumbnail requires fixed pixel dimensions.

Calling the API

typescript
const images = await editor.slides.exportImage(options);

All three modes accept these shared parameters:

ParameterTypeRequiredDefaultDescription
mode'view' | 'contain' | 'size'yes-Output-size calculation mode
slideIndicesnumber[]noall slides1-based indices of slides to export
format'png' | 'jpg' | 'svg'no'png'Image format
qualitynumberno0.92JPG quality from 0 to 1; applies only to JPG

view: export a specific viewport

The view mode treats viewBounds as the world-coordinate region to export. The camera is centered on that region. Output dimensions are calculated from the region's world dimensions, camera scale, and pixel ratio.

Mode-specific parameters

ParameterTypeRequiredDefaultDescription
viewBoundsExportViewBoundsyes-World-coordinate region to export
pixelRationumberno1Output pixel multiplier; must be greater than 0

Fields in ExportViewBounds:

FieldTypeRequiredDefaultDescription
xnumberyes-World-coordinate X of the viewport's top-left corner
ynumberyes-World-coordinate Y of the viewport's top-left corner
widthnumberyes-Width in world units; must be greater than 0
heightnumberyes-Height in world units; must be greater than 0
scalenumbernoslide camera.scalePixels per world unit; must be greater than 0

When viewBounds.scale is omitted, the SDK uses the target slide's camera.scale from the file. If the file does not provide it, the SDK uses 50.

Output dimensions are calculated as follows:

text
output width = viewBounds.width × scale × pixelRatio
output height = viewBounds.height × scale × pixelRatio
typescript
const images = await editor.slides.exportImage({
  mode: 'view',
  slideIndices: [1],
  format: 'png',
  viewBounds: {
    x: -5,
    y: -5,
    width: 10,
    height: 10,
    scale: 50,
  },
  pixelRatio: 2,
});

This example produces a 1000 × 1000 pixel image.

contain: include all content

The contain mode calculates the visual bounding box of the slide content and centers the output viewport on it. Visual extensions such as point radii and label text are included so content is not clipped. Final image dimensions vary with the content.

If the slide has no calculable content bounds—for example, it contains only coordinate axes—the original file camera viewport is preserved.

Mode-specific parameters

ParameterTypeRequiredDefaultDescription
pixelRationumberno1Output pixel multiplier; must be greater than 0
paddingnumber | { horizontal?: number; vertical?: number }no0Padding per side, in final output pixels

When padding is a number, the same value is applied to all four sides. When it is an object:

  • horizontal applies to both the left and right sides.
  • vertical applies to both the top and bottom sides.

Output dimensions are calculated as follows:

text
output width = content bounds width × camera.scale × pixelRatio + 2 × horizontal
output height = content bounds height × camera.scale × pixelRatio + 2 × vertical

camera.scale comes from the target slide file and defaults to 50 when absent.

typescript
const images = await editor.slides.exportImage({
  mode: 'contain',
  slideIndices: [1, 2],
  format: 'svg',
  pixelRatio: 1,
  padding: {
    horizontal: 24,
    vertical: 16,
  },
});

size: export exact dimensions

The size mode guarantees that the final image is exactly width × height. After subtracting minPadding from the available output area, the SDK automatically calculates a scale that fits the visual content bounds and centers the content.

The size mode does not accept pixelRatio.

Mode-specific parameters

ParameterTypeRequiredDefaultDescription
widthnumberyes-Exact output width in pixels; must be greater than 0
heightnumberyes-Exact output height in pixels; must be greater than 0
minPaddingnumber | { horizontal?: number; vertical?: number }no0Minimum padding per side, in output pixels

When minPadding is a number, the same value is applied to all four sides. When it is an object:

  • horizontal applies to both the left and right sides.
  • vertical applies to both the top and bottom sides.

The sum of the left and right padding must be less than width. The sum of the top and bottom padding must be less than height.

typescript
const images = await editor.slides.exportImage({
  mode: 'size',
  slideIndices: [1],
  format: 'jpg',
  width: 1200,
  height: 900,
  minPadding: {
    horizontal: 40,
    vertical: 32,
  },
  quality: 0.92,
});

Image export results

exportImage() returns Promise<ExportedSlideImage[]>. Each item has this shape:

typescript
interface ExportedSlideImage {
  index: number;
  blob: Blob;
  format: 'png' | 'jpg' | 'svg';
  width: number;
  height: number;
}
FieldDescription
index1-based slide index
blobExported image data
formatActual image format
widthImage width in pixels
heightImage height in pixels

For example, preview the first image in a browser:

typescript
const [image] = await editor.slides.exportImage({
  mode: 'contain',
  slideIndices: [1],
});

const url = URL.createObjectURL(image.blob);
previewImage.src = url;

// Release the URL when the preview no longer needs it.
previewImage.addEventListener('load', () => URL.revokeObjectURL(url), {
  once: true,
});

Export LaTeX/TikZ

LaTeX/TikZ is text source, not an image format. Do not pass format: 'latex' to exportImage(). Use:

typescript
const items = await editor.slides.exportLatex({
  slideIndices: [1, 3],
  standalone: true,
});

Parameters

ParameterTypeRequiredDefaultDescription
slideIndicesnumber[]noall slides1-based indices of slides to export
standalonebooleannotruetrue returns a complete compilable document; false returns only a TikZ fragment

The return type is Promise<ExportedLatex[]>. Each item has this shape:

typescript
interface ExportedLatex {
  index: number;
  code: string;
}