Screenshots and PDFs
Screenshots
Browserbase enables screen view and full-screen screenshots using your desired browser automation framework. For optimal performance, we recommend using CDP (Chrome DevTools Protocol) sessions to capture screenshots, as this method is significantly faster than standard approaches.
Save a screenshot locally
First, create a browser session and connect to it using your preferred framework. Then you can take a screenshot using CDP sessions for the best performance:
Why use CDP for screenshots?
Using CDP (Chrome DevTools Protocol) for taking screenshots offers several advantages:
- Performance: CDP screenshots are significantly faster than traditional methods
- Memory Efficiency: Uses less memory as it directly communicates with the browser’s debugging protocol
- Quality Control: Provides more control over image quality and format settings
- Reliability: More stable for full-page screenshots of complex web applications
For most use cases, we recommend using the CDP approach shown above rather than the standard screenshot methods.
PDFs
You can work with PDFs in two ways:
- Generate PDFs: Create PDFs from web pages using Playwright’s
page.pdf()
method (shown below) - Download PDFs: When a PDF is opened in the browser, it will be automatically downloaded and stored in Browserbase’s cloud storage. See the Downloads documentation for information on how to retrieve downloaded PDFs.
Generate a PDF locally
After creating and connecting to a session, here’s how to generate a PDF from a web page using Playwright: