r/GoogleAppsScript • u/VictorYBW • 4d ago
Question PrintScreen of the WebApp for Reports
Hey Guys
I have a Web App and I like a create a report of screenshot this WebApp.
But WebApp are in the Google Workplace, and report have needs parameters before report that a filter inside the WebApp.
Can you give me a north or that impossible?
Sorry my bad english xD
0
Upvotes
2
u/No-Sheepherder7116 10h ago
Not impossible, but the screenshot can't happen on the Apps Script side. Apps Script runs on Google's servers with no browser and no screen, so there is nothing for it to capture. The capture has to happen in the user's browser, after the filters are applied. That actually fits your case well, because the filters live in the Web App itself.
Option 1: the simple route — print the filtered view to PDF
Add a button to your Web App page that calls
window.print(), and add print CSS that hides the filter controls and buttons. The user applies the filters, clicks the button, and saves as PDF. What they see is exactly what goes in the report, and no server code is needed:Option 2: if you really need an image file saved to Drive
Capture the report in the browser with the html2canvas library, then send the image to a server function that saves it. Put the report inside an element with an id, for example
id="report", and add a save button.In your HTML file:
In
Code.gs:Two things to watch for:
doGet(e)withe.parameter, so the page loads already filtered before anyone captures it.If the report is just data from a Sheet, Option 1 is what I'd do. Use Option 2 only when you literally need a picture of the Web App.