Skip to content

Export

Render the Present-mode layout sheets to a downloadable file — PDF, PNG, or JPG — and receive the encoded bytes as base64. Accessed via snaptrude.presentation.export.

This wraps the same pipeline as the Present-mode Export dialog (each sheet is serialized to an SVG, then composed into a PDF or rasterized to an image), but instead of triggering a browser download it hands your plugin the bytes so you can save, upload, or preview them yourself.

Present mode required

Export needs Present mode (the documentation editor) open — it throws PRECONDITION_FAILED ("Present mode is not open") when it is closed.

At a glance

MethodWhat it doesMutates?
export(format, options?)Render sheets to PDF/PNG/JPG and return the bytes

Export is a read — it produces a file and never changes the scene, so it is not subject to the plugin write floor.

Types

PluginPresentationExportFile

A single exported file.

PropertyTypeDescription
fileNamestringFile name including extension
mimeTypestringMIME type (application/pdf, image/png, image/jpeg)
dataBase64stringThe file bytes, base64-encoded (no data: URL prefix)

PluginPresentationExportResolution

Target pixel dimensions for a rasterized (png/jpg) export. Ignored for pdf.

PropertyTypeDescription
widthnumberOutput width in pixels
heightnumberOutput height in pixels

Functions

export(format, options?)

Render the presentation sheets and return the encoded files.

  • Parameters:
    • format: "pdf" | "png" | "jpg" — output format
    • options.sheetIds: string[] | undefined — sheets to export (all sheets, in order, when omitted)
    • options.combine: boolean | undefinedPDF only: one multi-page file (default true) vs one file per sheet
    • options.resolution: { width, height } | undefined — raster target size (png/jpg only; ignored for pdf)
    • options.fileName: string | undefined — base file name without extension (defaults to the document title)
  • Returns: { files: PluginPresentationExportFile[] } — always a files array. A combined PDF yields one entry; per-sheet exports yield one entry per sheet, in sheet order.
  • Throws: If Present mode is not open, any sheetId is unknown, there are no sheets, or a sheet fails to serialize/encode.
ts
// A single combined PDF of every sheet:
const { files } = await snaptrude.presentation.export("pdf");
const pdf = files[0]; // { fileName, mimeType: "application/pdf", dataBase64 }

// PNGs of two specific sheets at 1920×1080:
const { sheets } = await snaptrude.presentation.sheets.list();
const { files: pngs } = await snaptrude.presentation.export("png", {
  sheetIds: [sheets[0].id, sheets[1].id],
  resolution: { width: 1920, height: 1080 },
  fileName: "floor-plans"
});
// pngs[0].dataBase64 → base64 PNG bytes

Errors

Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this method:

CodeWhendetails
VALIDATIONformat is not pdf/png/jpg, or resolution is malformed
PRECONDITION_FAILEDPresent mode is not open
HANDLE_INVALIDA sheetId does not match any sheet
OPERATION_FAILEDThere are no sheets to export, or a sheet failed to serialize / encodehandles — the sheet id