GitHub user dosubot[bot] added a comment to the discussion: How can I export an embedded dashboard to PDF?
<!-- Greeting --> Hi @Ramicorrea-Chimi! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team. <!-- Answer --> There are two main ways to export a Superset dashboard to PDF, but both have important limitations for embedded dashboards: **1. Superset App UI (Frontend)** The "Export to PDF" option in the Superset app uses a frontend component that captures the dashboard DOM and generates a PDF using the `dom-to-pdf` library. This works well in the main app, but in embedded scenarios (like iframes with guest tokens), it may not be available or may fail due to authentication or cross-origin issues. The export is limited to the visible viewport and desktop layout—scrollable content or mobile layouts are not fully captured, and large dashboards can cause browser hangs or incomplete exports. There’s no built-in support for ISO page sizes or configurable DPI, and only the current view is exported, not the entire scrollable dashboard [[source](https://github.com/apache/superset/issues/36794)]. **2. REST API (Screenshot/PDF Export)** Superset exposes a REST API for dashboard screenshots and PDF export, which is what the frontend uses. The flow is: - POST to `/api/v1/dashboard/{dashboardId}/cache_dashboard_screenshot/` to trigger screenshot generation (returns a cache key). - Poll `/api/v1/dashboard/{dashboardId}/screenshot/{cacheKey}/?download_format=pdf` to download the PDF once ready [[source](https://github.com/apache/superset/pull/30212)]. However, this API requires proper authentication and permissions. In embedded dashboards using guest tokens, PDF export often fails because the `GuestUser` class lacks a user ID and is inactive, causing login failures during PDF generation. Fixing this requires backend customization (extending `GuestUser` to implement `get_id` and set `is_active` to true) [[source](https://github.com/apache/superset/discussions/32502)]. **Workarounds** - Some users automate PDF export using browser automation tools like Playwright or Puppeteer, which can capture the full scrollable dashboard and bypass some frontend/API limitations. This is not built-in, but can be scripted externally [[source](https://github.com/apache/superset/issues/36794)]. - For dashboards with tabs, enabling `FEATURE_FLAGS = {"ALERT_REPORT_TABS": True}` will print each tab on a separate PDF page [[source](https://github.com/apache/superset/issues/36794)]. **Key Limitations** - PDF export is limited to a fixed width (1600px × pixel_density), 72 dpi, and does not support ISO page sizes or configurable DPI. - Only the visible viewport is exported; scrollable content is not included. - Authentication issues are common in embedded/guest token scenarios. - No direct REST API for "download embedded dashboard as PDF"—the closest is the screenshot API, but it may not work out-of-the-box for embedded dashboards. **Recommendation** If you need reliable, full-dashboard PDF export from an embedded context, browser automation (e.g., Playwright) is currently the most robust approach. If you control the backend, you can try customizing the `GuestUser` class to enable the REST API export for embedded dashboards, but this requires code changes. For simple use cases, the built-in UI export may suffice, but be aware of its viewport and authentication limitations. References: - [REST API screenshot/PDF export flow](https://github.com/apache/superset/pull/30212) - [Authentication and embedded dashboard export issues](https://github.com/apache/superset/discussions/32502) - [Export limitations and Playwright workaround](https://github.com/apache/superset/issues/36794) <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/174b03bb-a1f7-46fd-a4eb-4cfe24391555?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github) [](https://cursor.com/link/prompt?text=There%20are%20two%20main%20ways%20to%20export%20a%20Superset%20dashboard%20to%20PDF%2C%20but%20both%20have%20important%20limitations%20for%20embedded%20dashboards%3A%0A%0A%2A%2A1.%20Superset%20App%20UI%20%28Frontend%29%2A%2A%0AThe%20%22Export%20to%20PDF%22%20option%20in%20the%20Superset%20app%20uses%20a%20frontend%20component%20that%20captures%20the%20dashboard%20DOM%20and%20generates%20a%20PDF%20using%20the%20%60dom-to-pdf%60%20library.%20This%20works%20well%20in%20the%20main%20app%2C%20but%20in%20embedded%20scenarios%20%28like%20iframes%20with%20guest%20tokens%29%2C%20it%20may%20not%20be%20available%20or%20may%20fail%20due%20to%20authentication%20or%20cross-origin%20issues.%20The%20export%20is%20limited%20to%20the%20visible%20viewport%20and%20deskto p%20layout%E2%80%94scrollable%20content%20or%20mobile%20layouts%20are%20not%20fully%20captured%2C%20and%20large%20dashboards%20can%20cause%20browser%20hangs%20or%20incomplete%20exports.%20There%E2%80%99s%20no%20built-in%20support%20for%20ISO%20page%20sizes%20or%20configurable%20DPI%2C%20and%20only%20the%20current%20view%20is%20exported%2C%20not%20the%20entire%20scrollable%20dashboard%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/issues/36794%29%5D.%0A%0A%2A%2A2.%20REST%20API%20%28Screenshot/PDF%20Export%29%2A%2A%0ASuperset%20exposes%20a%20REST%20API%20for%20dashboard%20screenshots%20and%20PDF%20export%2C%20which%20is%20what%20the%20frontend%20uses.%20The%20flow%20is%3A%0A-%20POST%20to%20%60/api/v1/dashboard/%7BdashboardId%7D/cache_dashboard_screenshot/%60%20to%20trigger%20screenshot%20generation%20%28returns%20a%20cache%20key%29.%0A-%20Poll%20%60/api/v1/dashboard/%7BdashboardId%7D/screenshot/%7BcacheKey%7D/%3Fdownload_format%3Dpdf%60%20to%20download%20the%20PDF%20once%20r eady%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/pull/30212%29%5D.%0A%0AHowever%2C%20this%20API%20requires%20proper%20authentication%20and%20permissions.%20In%20embedded%20dashboards%20using%20guest%20tokens%2C%20PDF%20export%20often%20fails%20because%20the%20%60GuestUser%60%20class%20lacks%20a%20user%20ID%20and%20is%20inactive%2C%20causing%20login%20failures%20during%20PDF%20generation.%20Fixing%20this%20requires%20backend%20customization%20%28extending%20%60GuestUser%60%20to%20implement%20%60get_id%60%20and%20set%20%60is_active%60%20to%20true%29%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/discussions/32502%29%5D.%0A%0A%2A%2AWorkarounds%2A%2A%0A-%20Some%20users%20automate%20PDF%20export%20using%20browser%20automation%20tools%20like%20Playwright%20or%20Puppeteer%2C%20which%20can%20capture%20the%20full%20scrollable%20dashboard%20and%20bypass%20some%20frontend/API%20limitations.%20This%20is%20not%20built-in%2C%20but%20can%20be%20scripted%20externally%20%5B%5B source%5D%28https%3A//github.com/apache/superset/issues/36794%29%5D.%0A-%20For%20dashboards%20with%20tabs%2C%20enabling%20%60FEATURE_FLAGS%20%3D%20%7B%22ALERT_REPORT_TABS%22%3A%20True%7D%60%20will%20print%20each%20tab%20on%20a%20separate%20PDF%20page%20%5B%5Bsource%5D%28https%3A//github.com/apache/superset/issues/36794%29%5D.%0A%0A%2A%2AKey%20Limitations%2A%2A%0A-%20PDF%20export%20is%20limited%20to%20a%20fixed%20width%20%281600px%20%C3%97%20pixel_density%29%2C%2072%20dpi%2C%20and%20does%20not%20support%20ISO%20page%20sizes%20or%20configurable%20DPI.%0A-%20Only%20the%20visible%20viewport%20is%20exported%3B%20scrollable%20content%20is%20not%20included.%0A-%20Authentication%20issues%20are%20common%20in%20embedded/guest%20token%20scenarios.%0A-%20No%20direct%20REST%20API%20for%20%22download%20embedded%20dashboard%20as%20PDF%22%E2%80%94the%20closest%20is%20the%20screenshot%20API%2C%20but%20it%20may%20not%20work%20out-of-the-box%20for%20embedded%20dashboards.%0A%0A%2A%2ARecommendation%2A% 2A%0AIf%20you%20need%20reliable%2C%20full-dashboard%20PDF%20export%20from%20an%20embedded%20context%2C%20browser%20automation%20%28e.g.%2C%20Playwright%29%20is%20currently%20the%20most%20robust%20approach.%20If%20you%20control%20the%20backend%2C%20you%20can%20try%20customizing%20the%20%60GuestUser%60%20class%20to%20enable%20the%20REST%20API%20export%20for%20embedded%20dashboards%2C%20but%20this%20requires%20code%20changes.%20For%20simple%20use%20cases%2C%20the%20built-in%20UI%20export%20may%20suffice%2C%20but%20be%20aware%20of%20its%20viewport%20and%20authentication%20limitations.%0A%0AReferences%3A%20%20%0A-%20%5BREST%20API%20screenshot/PDF%20export%20flow%5D%28https%3A//github.com/apache/superset/pull/30212%29%20%20%0A-%20%5BAuthentication%20and%20embedded%20dashboard%20export%20issues%5D%28https%3A//github.com/apache/superset/discussions/32502%29%20%20%0A-%20%5BExport%20limitations%20and%20Playwright%20workaround%5D%28https%3A//github.com/apache/superset/issues/36794%29) [](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/36988) GitHub link: https://github.com/apache/superset/discussions/36988#discussioncomment-15448922 ---- This is an automatically sent email for [email protected]. To unsubscribe, please send an email to: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
