datalens-tech / datalens

A modern, scalable analytics system
https://datalens.tech
Apache License 2.0
1.28k stars 57 forks source link

Publisher/Presentation tools #50

Open zxan2 opened 9 months ago

zxan2 commented 9 months ago

добрый день, была бы полезна функциональность печати дашбоардов и экспорта как pdf

pashkov-v commented 8 months ago

I've implemented PDF reports generation based on DataLens dashboards using Puppeteer. There are several major obstacles in this approach.

  1. One should pass page width for each tab so that all elements fit into PDF page. Page height is available via .react-grid-layout.
  2. DataLens loads widgets lazily, hence one needs to set viewport size equal to the page size so that all elements are loaded simultaneously. But in this way, a single tab with many widgets may load longer than default navigation timeout of 30 seconds, so one needs to adjust this timeout. Plus one may get errors from data source because it may not allow too many simultaneous connections.
  3. .dash-tabs element breaks PDF page width in case of a dashboard with multiple tabs. So it should be removed from the page before executing page.pdf() (although in my opinion horizontal tabs list is pointless in case of PDF reports, so that's a good thing that they should be removed).

It is also possible to remove some buttons from web page before rendering it as PDF.