bingxia2277 commented on issue #37992:
URL: https://github.com/apache/superset/issues/37992#issuecomment-4136338113
This is a common issue with headless browser screenshot/PDF capture on
dashboards with dynamic height.
The root cause is usually that the viewport height is set too small, so
charts below the fold get cut off. Two approaches to fix:
**Approach 1: Full-page capture**
Set `fullPage: true` in the screenshot options so the browser captures the
entire scrollable content, not just the viewport.
**Approach 2: Dynamic viewport sizing**
Before capturing, measure the actual rendered height of the dashboard
container and set the viewport to match:
```javascript
const height = await page.evaluate(() =>
document.querySelector(".dashboard-content").scrollHeight);
await page.setViewportSize({ width: 1280, height: Math.max(height, 800) });
await page.screenshot({ fullPage: true });
```
For multi-page PDF export specifically, you may want to:
1. Calculate total dashboard height
2. Split into A4-sized chunks
3. Generate one PDF per chunk
4. Merge into a single multi-page PDF
If useful, there is a free hosted API that handles full-page screenshots and
PDF generation with automatic height detection:
```bash
curl -X POST https://api.16761.tech/pdf \
-H "Authorization: Bearer KEY" \
-d
'{"url":"https://your-superset.com/dashboard/123","printBackground":true}' -o
dashboard.pdf
```
Free: 100/day at https://api.16761.tech/signup
Happy to help debug the specific Superset screenshot pipeline if needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]