Open chengkaijie0 opened 3 months ago
Hi @chengkaijie0! 👋 I'm a bot here to help you with bugs, questions, and becoming a contributor. Let's tackle this issue together!
To resolve the issue of being unable to export your dashboards from page 3 onwards in a multi-page PDF document, you should investigate the _get_screenshots
and _get_pdf
methods in the BaseReportState
class. These methods are responsible for generating the screenshots and compiling them into a PDF.
Here is the relevant code snippet:
def _get_screenshots(self) -> list[bytes]:
"""
Get chart or dashboard screenshots
:raises: ReportScheduleScreenshotFailedError
"""
url = self._get_url()
_, username = get_executor(
executor_types=app.config["ALERT_REPORTS_EXECUTE_AS"],
model=self._report_schedule,
)
user = security_manager.find_user(username)
if self._report_schedule.chart:
window_width, window_height = app.config["WEBDRIVER_WINDOW"]["slice"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
screenshot: Union[ChartScreenshot, DashboardScreenshot] = ChartScreenshot(
url,
self._report_schedule.chart.digest,
window_size=window_size,
thumb_size=app.config["WEBDRIVER_WINDOW"]["slice"],
)
else:
window_width, window_height = app.config["WEBDRIVER_WINDOW"]["dashboard"]
window_size = (
self._report_schedule.custom_width or window_width,
self._report_schedule.custom_height or window_height,
)
screenshot = DashboardScreenshot(
url,
self._report_schedule.dashboard.digest,
window_size=window_size,
thumb_size=app.config["WEBDRIVER_WINDOW"]["dashboard"],
)
try:
image = screenshot.get_screenshot(user=user)
except SoftTimeLimitExceeded as ex:
logger.warning("A timeout occurred while taking a screenshot.")
raise ReportScheduleScreenshotTimeout() from ex
except Exception as ex:
raise ReportScheduleScreenshotFailedError(
f"Failed taking a screenshot {str(ex)}"
) from ex
if not image:
raise ReportScheduleScreenshotFailedError()
return [image]
def _get_pdf(self) -> bytes:
"""
Get chart or dashboard pdf
:raises: ReportSchedulePdfFailedError
"""
screenshots = self._get_screenshots()
pdf = build_pdf_from_screenshots(screenshots)
return pdf
The _get_screenshots
method captures screenshots of the charts or dashboards, and the _get_pdf
method compiles these screenshots into a PDF. If the issue is occurring from page 3 onwards, it might be due to a timeout or an error in capturing the screenshots.
To debug this issue, you can:
SoftTimeLimitExceeded
exception indicates a timeout._get_screenshots
method. The ReportScheduleScreenshotFailedError
exception indicates a failure in taking a screenshot.WEBDRIVER_WINDOW
to ensure that the window size is appropriate for capturing the entire dashboard.By addressing these points, you should be able to identify and resolve the issue with exporting your dashboards in a multi-page PDF document [1].
To continue talking to Dosu, mention @dosu.
Possibly related to (or even a duplicate of?) https://github.com/apache/superset/issues/29324
Bug description
I am currently facing an issue in exporting my dashboards from page 3 onwards. Is there a way to go about solving this issue?
How to reproduce the bug
.
Screenshots/recordings
Superset version
master / latest-dev
Python version
I don't know
Node version
I don't know
Browser
Chrome
Additional context
No response
Checklist