GitHub user aashish254 added a comment to the discussion: Superset download 
image and pdf issue

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.


GitHub link: 
https://github.com/apache/superset/discussions/45443#discussioncomment-19035741

----
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]

Reply via email to