Export PDF, Image & ZIP
Generate high-fidelity PDFs, images, and ZIP archives from the current design. All three use server-side headless Chromium rendering.
- React
- Vue
- Angular
- Vanilla JS
import { useRef } from "react";
import { DragbleEditor, DragbleEditorRef } from "dragble-react-editor";
function ExportDemo() {
const editorRef = useRef<DragbleEditorRef>(null);
const handleExportImage = async () => {
const result = await editorRef.current?.editor?.exportImage({
format: "png",
width: 640,
fullPage: true,
});
if (result?.imageData) {
// imageData is a base64 data-URL: "data:image/png;base64,..."
window.open(result.imageData);
}
};
const handleExportPdf = async () => {
const result = await editorRef.current?.editor?.exportPdf({
pageSize: "a4",
orientation: "portrait",
});
if (result?.pdfData) {
const a = document.createElement("a");
a.href = result.pdfData;
a.download = "template.pdf";
a.click();
}
};
const handleExportZip = async () => {
const result = await editorRef.current?.editor?.exportZip({
imageFolder: "images",
});
if (result?.zipData) {
const a = document.createElement("a");
a.href = result.zipData;
a.download = "template.zip";
a.click();
}
};
return (
<>
<DragbleEditor
ref={editorRef}
editorKey="db_your_key"
editorMode="email"
/>
<button onClick={handleExportImage}>Export Image</button>
<button onClick={handleExportPdf}>Export PDF</button>
<button onClick={handleExportZip}>Export ZIP</button>
</>
);
}
<template>
<DragbleEditor ref="editorRef" editor-key="db_your_key" editor-mode="email" />
<button @click="handleExportImage">Export Image</button>
<button @click="handleExportPdf">Export PDF</button>
<button @click="handleExportZip">Export ZIP</button>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { DragbleEditor } from "dragble-vue-editor";
const editorRef = ref<InstanceType<typeof DragbleEditor>>();
async function handleExportImage() {
const result = await editorRef.value?.exportImage({
format: "png",
width: 640,
fullPage: true,
});
if (result?.imageData) {
window.open(result.imageData);
}
}
async function handleExportPdf() {
const result = await editorRef.value?.exportPdf({
pageSize: "a4",
orientation: "portrait",
});
if (result?.pdfData) {
const a = document.createElement("a");
a.href = result.pdfData;
a.download = "template.pdf";
a.click();
}
}
async function handleExportZip() {
const result = await editorRef.value?.exportZip({ imageFolder: "images" });
if (result?.zipData) {
const a = document.createElement("a");
a.href = result.zipData;
a.download = "template.zip";
a.click();
}
}
</script>
import { Component, ViewChild } from "@angular/core";
import { DragbleEditorComponent } from "dragble-angular-editor";
import type { DragbleSDK } from "dragble-types";
@Component({
selector: "app-export-demo",
standalone: true,
imports: [DragbleEditorComponent],
template: `
<dragble-editor
#editor
editorKey="db_your_key"
editorMode="email"
(ready)="onReady($event)"
></dragble-editor>
<button (click)="handleExportImage()">Export Image</button>
<button (click)="handleExportPdf()">Export PDF</button>
<button (click)="handleExportZip()">Export ZIP</button>
`,
})
export class ExportDemoComponent {
@ViewChild("editor") editorComp!: DragbleEditorComponent;
private sdk: DragbleSDK | null = null;
onReady(sdk: DragbleSDK) {
this.sdk = sdk;
}
async handleExportImage() {
const result = await this.sdk?.exportImage({
format: "png",
width: 640,
fullPage: true,
});
if (result?.imageData) {
window.open(result.imageData);
}
}
async handleExportPdf() {
const result = await this.sdk?.exportPdf({
pageSize: "a4",
orientation: "portrait",
});
if (result?.pdfData) {
const a = document.createElement("a");
a.href = result.pdfData;
a.download = "template.pdf";
a.click();
}
}
async handleExportZip() {
const result = await this.sdk?.exportZip({ imageFolder: "images" });
if (result?.zipData) {
const a = document.createElement("a");
a.href = result.zipData;
a.download = "template.zip";
a.click();
}
}
}
// Export as PNG
const imageResult = await dragble.exportImage({
format: "png",
width: 640,
fullPage: true,
});
if (imageResult.imageData) {
window.open(imageResult.imageData);
}
// Export as PDF
const pdfResult = await dragble.exportPdf({
pageSize: "a4",
orientation: "portrait",
});
if (pdfResult.pdfData) {
const a = document.createElement("a");
a.href = pdfResult.pdfData;
a.download = "template.pdf";
a.click();
}
// Export as ZIP
const zipResult = await dragble.exportZip({ imageFolder: "images" });
if (zipResult.zipData) {
const a = document.createElement("a");
a.href = zipResult.zipData;
a.download = "template.zip";
a.click();
}
:::info Server-side rendering
These exports are rendered server-side by Dragble using headless Chromium. They are not available in popup editor mode. Use exportHtml() instead for popups.
:::
Image export options​
const result = await editor.exportImage({
format: "png", // 'png' | 'jpg'
width: 640, // Output width in pixels (100–2000, default 640)
height: null, // Viewport height, null = auto (default null)
fullPage: true, // Capture full scrollable page (default true)
quality: 90, // JPEG quality 1–100, ignored for PNG (default 90)
deviceScaleFactor: 2, // 1–3, use 2 for retina (default 1)
saveToStorage: false, // true = upload and return URL, false = base64 data-URL
mergeTags: {
// Replace merge tags before rendering
first_name: "Jane",
},
});
| Option | Type | Default | Description |
|---|---|---|---|
format | 'png' | 'jpg' | 'png' | Output image format |
width | number | 640 | Output width in pixels (100–2000) |
height | number | null | null | Viewport height. null = auto-height |
fullPage | boolean | true | Capture full scrollable page vs viewport only |
quality | number | 90 | JPEG quality (1–100). Ignored for PNG |
deviceScaleFactor | number | 1 | Scale factor (1–3). Use 2 for retina displays |
saveToStorage | boolean | false | Upload to Dragble storage and return a hosted URL |
mergeTags | Record<string, string> | undefined | Merge tag replacements applied before rendering |
Return value (ExportImageData):
imageData— base64 data-URL whensaveToStorageisfalse(default)url— hosted URL whensaveToStorageistruedesign— the design JSON at the time of export
PDF export options​
const result = await editor.exportPdf({
pageSize: "a4", // 'full' | 'letter' | 'a4' | 'a3'
orientation: "portrait", // 'portrait' | 'landscape' (ignored for 'full')
printBackground: true, // Include CSS backgrounds (default true)
margin: {
// Page margins in CSS units
top: "10mm",
right: "10mm",
bottom: "10mm",
left: "10mm",
},
width: 768, // Viewport width in CSS pixels (default 768)
saveToStorage: false, // true = upload and return URL
mergeTags: {
// Replace merge tags before rendering
company: "Acme Inc.",
},
});
| Option | Type | Default | Description |
|---|---|---|---|
pageSize | 'full' | 'letter' | 'a4' | 'a3' | 'full' | Page size preset. 'full' = single continuous page |
orientation | 'portrait' | 'landscape' | 'portrait' | Page orientation. Ignored when pageSize is 'full' |
printBackground | boolean | true | Include CSS background colors and images |
margin | { top?, right?, bottom?, left? } | undefined | Page margins in CSS units (e.g. '10mm') |
width | number | 768 | Viewport width in CSS pixels |
saveToStorage | boolean | false | Upload to Dragble storage and return a hosted URL |
mergeTags | Record<string, string> | undefined | Merge tag replacements applied before rendering |
Return value (ExportPdfData):
pdfData— base64 data-URL whensaveToStorageisfalse(default)url— hosted URL whensaveToStorageistruedesign— the design JSON at the time of export
ZIP export options​
The ZIP archive bundles the HTML template with all referenced images downloaded locally.
const result = await editor.exportZip({
imageFolder: "images", // Folder name inside ZIP for images (default 'images')
});
| Option | Type | Default | Description |
|---|---|---|---|
imageFolder | string | 'images' | Folder name for images inside the ZIP archive |
Return value (ExportZipData):
zipData— base64 data-URL of the ZIP archivedesign— the design JSON at the time of export
Save exports to Dragble storage​
Set saveToStorage: true on image and PDF exports to upload the result to Dragble's managed storage. The return value will include a url field with the hosted URL instead of a base64 data-URL:
const result = await editor.exportImage({
format: "png",
saveToStorage: true,
});
console.log(result.url);
// "https://assets.dragble.com/exports/abc123.png"
Method reference​
| Method | Returns | Description |
|---|---|---|
exportImage(options?) | Promise<ExportImageData> | Export as PNG or JPG image (server-side rendered) |
exportPdf(options?) | Promise<ExportPdfData> | Export as PDF document (server-side rendered) |
exportZip(options?) | Promise<ExportZipData> | Export as ZIP with HTML + images |
Next steps​
- Export HTML — client-side HTML export
- Load & Save Designs — persist and reload designs
- Merge Tags — dynamic content in exports