Skip to content

Commit

Permalink
Create captureRenderedHtml utility
Browse files Browse the repository at this point in the history
  • Loading branch information
gramliu committed Nov 29, 2023
1 parent 9325047 commit 1144392
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions apps/agent/src/lib/render/capture_html.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import puppeteer from "puppeteer";

/**
* Captures the rendered HTML as a screenshot.
*/
export async function captureRenderedHtml(html: string) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setViewport({ width: 1920, height: 1080 });
await page.setContent(html, {
timeout: 60_000,
});
await page.screenshot({ path: "screenshot.png", fullPage: true });
}

0 comments on commit 1144392

Please sign in to comment.