Repository navigation
Superset download image and pdf issue #45443
Replies: 3 comments 2 replies
|
the download buttons do not take a screenshot of what you see on screen. they re-render the dashboard dom in your browser: the image export clones the .dashboard node and copies over only a fixed list of about 45 critical css properties (display, position, width and height, margins, padding, font-, color, background-color, border-, opacity, flex and grid bits) before rasterizing it with dom-to-image, and the pdf export re-renders the live element with html2canvas. you can see this in superset-frontend/src/utils/downloadAsImage.tsx, the CRITICAL_STYLE_PROPERTIES set and copyAllComputedStyles, and in superset-frontend/src/utils/downloadAsPdf.ts. so your dashboard css is not exactly ignored, but anything outside that property list never makes it into the png: box-shadow, border-radius, gap, filters, pseudo-element styling, animations, media queries and :hover states are all dropped, which is why the graphs look different in the download. the css editor content gets injected as a style tag in the page head (src/dashboard/util/injectCustomCss.ts), so rules that reduce to the basic properties above do carry over. if you want the exports to match the screen, keep the export css to simple selectors with the basics like colors, fonts, spacing and borders, and avoid the fancy properties. worth knowing the scheduled email reports path is different, that one renders the real page in headless chromium (superset/utils/screenshots.py), so it is a much closer wysiwyg than the menu downloads. |
|
@dosu even if I remove all css i am not getting proper downloaded image
|
|
The squashed image output (width 1918px with small height) happens because client-side export handles DOM rendering differently from on-screen display. Why Client-Side Export Shrinks or DistortsWhen you click Download as Image or Download as PDF from the dashboard menu:
Steps to Fix the Squashed Output
/* Avoid these on dashboard chart containers */
.dashboard-component-chart-holder {
overflow: hidden !important;
max-height: 350px !important;
}Instead, let the chart component compute its dimensions: .dashboard-component-chart-holder {
overflow: visible !important;
}
|

Uh oh!
There was an error while loading. Please reload this page.
Does superset do not retain or use the css that we have added in theme css?
why ?
it is not applying during downloading or the graphs are not looking same in downloaded image and pdf
All reactions