Appearance
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
| Method | What it does | Mutates? |
|---|---|---|
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.
| Property | Type | Description |
|---|---|---|
fileName | string | File name including extension |
mimeType | string | MIME type (application/pdf, image/png, image/jpeg) |
dataBase64 | string | The file bytes, base64-encoded (no data: URL prefix) |
PluginPresentationExportResolution
Target pixel dimensions for a rasterized (png/jpg) export. Ignored for pdf.
| Property | Type | Description |
|---|---|---|
width | number | Output width in pixels |
height | number | Output height in pixels |
Functions
export(format, options?)
Render the presentation sheets and return the encoded files.
- Parameters:
format:"pdf" | "png" | "jpg"— output formatoptions.sheetIds:string[] | undefined— sheets to export (all sheets, in order, when omitted)options.combine:boolean | undefined— PDF only: one multi-page file (defaulttrue) vs one file per sheetoptions.resolution:{ width, height } | undefined— raster target size (png/jpgonly; ignored forpdf)options.fileName:string | undefined— base file name without extension (defaults to the document title)
- Returns:
{ files: PluginPresentationExportFile[] }— always afilesarray. 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
sheetIdis 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 bytesErrors
Failed calls reject with a typed PluginError — see Error Handling. Conditions specific to this method:
| Code | When | details |
|---|---|---|
VALIDATION | format is not pdf/png/jpg, or resolution is malformed | — |
PRECONDITION_FAILED | Present mode is not open | — |
HANDLE_INVALID | A sheetId does not match any sheet | — |
OPERATION_FAILED | There are no sheets to export, or a sheet failed to serialize / encode | handles — the sheet id |