Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to completely export to PDF grafana long tables #6

Open
fsalmoir opened this issue Sep 4, 2024 · 0 comments
Open

Unable to completely export to PDF grafana long tables #6

fsalmoir opened this issue Sep 4, 2024 · 0 comments

Comments

@fsalmoir
Copy link

fsalmoir commented Sep 4, 2024

Hello,

first of all my compliments for the tool, which could be very useful to all grafana users.

While trying to export to PDF long tables (by long I mean with scroll on the right side, as in picture below), I realized the tool is exporting just a part of it (top part).

This is the table report (in view panel) I want to export:

image

This is what I get in the export:

image

What I am expecting is to export all the rows of the table, no matter is they are visualized at the current moment in the panel (otherwise I could use "print to PDF" in web browser directly, without cloning container, installing docker, run container, config it, etc.

It seems to me the tool is not getting the right height. I am attaching the docker log for better reference (look at line "Page height adjusted to: 800"):

2024-09-04 13:45:10 Server is listening on port 3001
2024-09-04 13:48:17 Script grafana_pdf.js started...
2024-09-04 13:48:17 PDF width set to: 2000
2024-09-04 13:48:17 URL provided: http://192.168.11.84:3000/d/d36ff238-208d-4383-b56c-e5dbf1c4d255/doffing-performance?orgId=1&from=1724845696708&to=1725450496708&viewPanel=5&theme=light
2024-09-04 13:48:17 Checking URL accessibility...
2024-09-04 13:48:17 (node:14) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
2024-09-04 13:48:17 (Use `node --trace-deprecation ...` to show where the warning was created)
2024-09-04 13:48:17 Checking if kiosk mode is enabled.
2024-09-04 13:48:17 Kiosk mode not enabled. Enabling it.
2024-09-04 13:48:17 Kiosk mode enabled.
2024-09-04 13:48:17 Starting browser...
2024-09-04 13:48:18 Browser started...
2024-09-04 13:48:18 Navigating to URL...
2024-09-04 13:48:22 Page loaded...
2024-09-04 13:48:22 Extracting dashboard name and date from the HTML page...
2024-09-04 13:48:22 Dashboard name not found. Using default value.
2024-09-04 13:48:22 Date not found. Using default value.
2024-09-04 13:48:22 Debug HTML file saved at: ./debug/debug_output_grafana_2024-09-04_uy4xef.html
2024-09-04 13:48:22 Page height adjusted to: 800
2024-09-04 13:48:22 Generating PDF...
2024-09-04 13:48:22 PDF generated: ./output/output_grafana_2024-09-04_dtxnx.pdf
2024-09-04 13:48:22 Browser closed.

I cloned just yesterday the ExportGrafanaDashboardToPDF, so it is the latest release.

I am using grafana Grafana v11.2.0 (c57667e448) but I was able to test it (with same result) on grafana Grafana v10.1.1 (0cfa76b22d)

I guess the problem is something around these lines of the grafana_pdf.js file

        await page.evaluate(async () => {
            const scrollableSection = document.querySelector('.scrollbar-view');
            if (scrollableSection) {
                const childElement = scrollableSection.firstElementChild;
                let scrollPosition = 0;
                let viewportHeight = window.innerHeight;

                while (scrollPosition < childElement.scrollHeight) {
                    scrollableSection.scrollBy(0, viewportHeight);
                    await new Promise(resolve => setTimeout(resolve, 500));
                    scrollPosition += viewportHeight;
                }
            }
        });

but I was not able to fix it.

Thanks in advance for the support.

Filippo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant