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:- Node.js
- Python
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
PDFs
You can work with PDFs in a few ways:- Generate PDFs: Create PDFs from web pages using Playwright’s
page.pdf()
method (shown below) - Download PDFs: When a URL of a PDF is opened in the browser, the browser’s default behavior is to automatically download and store the PDF file in Browserbase’s cloud storage. See the Downloads documentation for information on how to retrieve downloaded PDFs.
- View PDFs in browser: If you’d like to view a PDF directly in the browser tab rather than download the PDF automatically, you can do so by turning on the
enablePdfViewer
property in your browser settings (shown below).
Generate a PDF locally
After creating and connecting to a session, here’s how to generate a PDF from a web page using Playwright:- Node.js
Playwright
Download a PDF from a URL
When you navigate to a PDF URL, Browserbase automatically downloads the PDF file and cancels the navigation. The downloaded PDF is stored in Browserbase’s cloud storage for later retrieval.- Node.js
- Python
View a PDF in browser
To view a PDF in the browser tab instead of automatically downloading it, you can set theenablePdfViewer
property to true as follows:
- Node.js
- Python