Export and Embedding
The MATIH platform provides comprehensive export and embedding capabilities for sharing dashboards, charts, query results, and reports outside the platform. Users can export content in multiple formats (PDF, PNG, CSV, Excel, JSON), embed interactive dashboards via iframe, schedule automated report delivery, and generate shareable links with configurable access controls. This section covers the export system architecture, embedding integration, and scheduled report delivery.
Export System Architecture
The export system spans three layers: client-side export for immediate downloads, server-side rendering for high-fidelity output, and scheduled exports for automated delivery.
+-----------------------------------------------------------+
| Export Trigger |
| [Export button] [Keyboard shortcut] [Scheduled job] |
+-----------------------------------------------------------+
| | |
v v v
+-------------+ +----------------+ +--------------+
| Client-side | | Server-side | | Scheduled |
| Export | | Render Service | | Export |
| (browser) | | (Node.js 8098) | | (cron) |
+-------------+ +----------------+ +--------------+
| | |
v v v
+-------------+ +----------------+ +--------------+
| Download | | Download or | | Email / S3 / |
| to browser | | store in S3 | | Webhook |
+-------------+ +----------------+ +--------------+Client-Side Export
Client-side export uses browser APIs and JavaScript libraries for immediate content download.
Export Formats
| Format | Library | Content Types | Max Size |
|---|---|---|---|
jspdf + html2canvas | Dashboards, reports, charts | ~50 pages | |
| PNG | html2canvas | Charts, dashboard snapshots, lineage | 4096x4096 px |
| SVG | D3.js native export | Individual charts | Unlimited |
| CSV | Custom generator | Query results, data tables | ~1M rows |
| Excel (XLSX) | xlsx library | Tabular data with formatting | ~1M rows |
| JSON | JSON.stringify | API responses, configurations, metadata | ~100 MB |
Export Dialog
The shared ExportDialog component at frontend/shared/src/components/Export/ExportDialog.tsx provides a unified export interface:
+-----------------------------------------------------------+
| Export Dashboard: Q4 Revenue Analysis |
+-----------------------------------------------------------+
| |
| Format: |
| [x] PDF [ ] PNG [ ] CSV [ ] Excel |
| |
| Options: |
| Page size: [A4 Landscape v] |
| Quality: [High v] |
| Include filters: [x] |
| Include title: [x] |
| Include timestamp: [x] |
| |
| Preview: |
| +---------------------------------------------------+ |
| | [Thumbnail preview of exported content] | |
| +---------------------------------------------------+ |
| |
| [Cancel] [Export] |
+-----------------------------------------------------------+Export Hook
The useExport hook at frontend/shared/src/hooks/useExport.ts provides the programmatic API:
interface ExportOptions {
target: string; // CSS selector of element to capture
filename?: string; // Output filename (without extension)
format?: 'pdf' | 'png' | 'csv' | 'xlsx' | 'json';
options?: {
orientation?: 'portrait' | 'landscape';
pageSize?: 'A4' | 'A3' | 'Letter' | 'Legal';
quality?: 'low' | 'medium' | 'high';
margin?: { top: number; right: number; bottom: number; left: number };
includeFilters?: boolean;
includeTimestamp?: boolean;
scale?: number; // Pixel ratio for PNG (1x, 2x, 3x)
};
}
export function useExport() {
const [isExporting, setIsExporting] = useState(false);
const [progress, setProgress] = useState(0);
const exportToPdf = useCallback(async (options: ExportOptions) => { /* ... */ }, []);
const exportToPng = useCallback(async (options: ExportOptions) => { /* ... */ }, []);
const exportToCsv = useCallback(async (data: CsvExportData) => { /* ... */ }, []);
const exportToExcel = useCallback(async (data: ExcelExportData) => { /* ... */ }, []);
const exportToJson = useCallback(async (data: unknown, filename: string) => { /* ... */ }, []);
return { isExporting, progress, exportToPdf, exportToPng, exportToCsv, exportToExcel, exportToJson };
}PDF Export Process
1. User clicks Export PDF
|
v
2. html2canvas captures the target element as a canvas
- Respects CSS transforms, shadows, and gradients
- Handles cross-origin images via proxy
- Applies scale factor for print quality (2x default)
|
v
3. Canvas is converted to PNG data URL
|
v
4. jspdf creates a PDF document
- Sets page orientation and size
- Adds margins
- Splits content across pages if needed
- Adds header (title, timestamp) and footer (page numbers)
|
v
5. PDF is saved to the browser downloadServer-Side Rendering
For high-fidelity exports and scheduled reports, the Render Service (Node.js, port 8098) provides server-side rendering:
Render Service Capabilities
| Capability | Description |
|---|---|
| Dashboard rendering | Full dashboard capture with all widgets |
| Chart rendering | Individual chart rendering with data |
| Report generation | Multi-page reports with table of contents |
| Thumbnail generation | Dashboard thumbnails for catalog views |
| Batch export | Multiple dashboards in a single request |
Render API
POST /render/v1/dashboard/{dashboardId}/pdf
POST /render/v1/dashboard/{dashboardId}/png
POST /render/v1/chart/{chartId}/png
POST /render/v1/chart/{chartId}/svg
POST /render/v1/report/generateRender Request
{
"dashboardId": "dash-123",
"format": "pdf",
"options": {
"width": 1920,
"height": 1080,
"scale": 2,
"orientation": "landscape",
"pageSize": "A4",
"includeFilters": true,
"filterValues": {
"region": "Western",
"dateRange": "last_30_days"
},
"waitForSelector": ".chart-rendered",
"timeout": 30000
}
}Dashboard Embedding
Dashboards can be embedded in external applications via iframe with configurable access controls.
Embedding Methods
| Method | Authentication | Use Case |
|---|---|---|
| Signed URL | Time-limited signed token | Temporary sharing with external users |
| API key | Tenant-scoped API key | Embedded in internal applications |
| SSO passthrough | Organization SSO | Embedded in authenticated portals |
| Public link | No authentication | Public dashboards (explicitly enabled) |
Iframe Integration
<!-- Embed a MATIH dashboard -->
<iframe
src="https://platform.matih.ai/embed/dashboards/dash-123?token=eyJ..."
width="100%"
height="600"
frameborder="0"
allow="fullscreen"
sandbox="allow-scripts allow-same-origin allow-popups"
></iframe>Embed Configuration
| Parameter | Type | Description |
|---|---|---|
token | string | Signed authentication token |
theme | light | dark |
hideHeader | boolean | Hide the dashboard title bar |
hideFilters | boolean | Hide the filter bar |
filterValues | JSON | Pre-applied filter values |
refreshInterval | number | Auto-refresh interval in seconds |
interactionMode | view | explore |
Embed Security
| Security Measure | Implementation |
|---|---|
| Token expiration | Signed URLs expire after configurable duration (default: 24 hours) |
| Tenant scoping | Embedded content is scoped to the tenant context in the token |
| Row-level security | All RLS policies apply to embedded views |
| CORS policy | Embedding domain must be whitelisted in tenant configuration |
| Content Security Policy | frame-ancestors header restricts which domains can embed |
| Rate limiting | Embedded views have separate rate limits to prevent abuse |
Scheduled Reports
Scheduled reports automate recurring export and delivery.
Schedule Configuration
+-----------------------------------------------------------+
| Schedule Report: Weekly Revenue Summary |
+-----------------------------------------------------------+
| |
| Dashboard: [Q4 Revenue Analysis v] |
| |
| Schedule: |
| Frequency: [Weekly v] |
| Day: [Monday v] |
| Time: [08:00 AM v] |
| Timezone: [America/New_York v] |
| |
| Format: [x] PDF [ ] PNG [ ] CSV |
| |
| Filters: |
| Region: [Dynamic: user's region v] |
| Date range: [Rolling: last 7 days v] |
| |
| Delivery: |
| [x] Email to: [team@company.com, ceo@company.com] |
| [ ] Upload to S3: [s3://reports/weekly/] |
| [ ] Webhook: [https://hooks.slack.com/...] |
| |
| [Cancel] [Schedule Report] |
+-----------------------------------------------------------+Delivery Channels
| Channel | Configuration | Description |
|---|---|---|
| Recipient list | PDF/PNG attached to email with summary | |
| S3 / GCS / Azure Blob | Bucket and path | File uploaded to cloud storage |
| Webhook | URL | POST request with file URL and metadata |
| Slack | Channel or DM | File posted to Slack with message |
Scheduled Report Flow
1. Scheduler triggers at configured time (cron)
|
v
2. Report Service retrieves dashboard configuration
|
v
3. Dynamic filter values are resolved
(e.g., "last 7 days" calculated from current date)
|
v
4. Render Service generates the export
- Renders dashboard with resolved filters
- Produces PDF/PNG/CSV
|
v
5. Delivery Service distributes the report
- Sends emails with attachments
- Uploads to cloud storage
- Triggers webhooks
|
v
6. Delivery confirmation logged in audit trailShareable Links
The platform supports generating shareable links with configurable access controls:
Link Types
| Link Type | Authentication | Expiration | Use Case |
|---|---|---|---|
| Workspace link | Requires login | Never | Share with team members |
| Signed link | Token in URL | Configurable (1h - 30d) | Share with external stakeholders |
| Public link | None | Never (until revoked) | Public dashboards |
| Snapshot link | None | Configurable | Point-in-time snapshot of data |
Link Generation
// Generate a shareable link
const shareLink = await biService.createShareLink({
dashboardId: 'dash-123',
type: 'signed',
expiresIn: '7d',
permissions: {
canFilter: true,
canDrillDown: true,
canExport: false,
},
filterValues: {
region: 'Western',
},
});
// Returns: https://platform.matih.ai/share/dash-123?token=eyJ...Export in Workbench Context
Each workbench provides context-specific export capabilities:
| Workbench | Export Targets | Formats |
|---|---|---|
| BI Workbench | Dashboards, charts, query results, metrics | PDF, PNG, CSV, Excel, SVG |
| Data Workbench | Query results, lineage diagrams, quality reports | CSV, JSON, PNG, PDF |
| ML Workbench | Experiment results, model comparison, training curves | CSV, PDF, PNG |
| Agentic Workbench | Conversation transcripts, generated SQL, workflow definitions | PDF, JSON, YAML |
| Ops Workbench | Health reports, incident timelines, cost reports | PDF, CSV |
| Control Plane UI | Audit logs, usage reports, tenant summaries | CSV, PDF, Excel |
Key Source Files
| Component | Location |
|---|---|
| Export dialog | frontend/shared/src/components/Export/ExportDialog.tsx |
| Export hook | frontend/shared/src/hooks/useExport.ts |
| Render service API | frontend/shared/src/api/render.ts |
| BI service (sharing) | frontend/shared/src/api/bi.ts |
| Dashboard export (BI) | frontend/bi-workbench/src/components/dashboard/ |