DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk4 min

How to Screenshot a Long Webpage in PHP with Symfony Panther

Symfony Panther documents screenshots of the current page, not guaranteed full-page capture. Try resizing the WebDriver window to the document dimensions, then validate the output.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Symfony Panther’s documented $client->takeScreenshot('screen.png') captures the current page, but Symfony does not promise that it captures the full document height. For a long page, you can try a community-reported workaround: read the document’s scroll dimensions with JavaScript, resize the WebDriver window to those dimensions, then take the screenshot. Validate the result in your own browser and driver setup; it is not a guaranteed Panther full-page API.

What Panther’s screenshot method captures

Panther runs a real browser through WebDriver and can execute JavaScript and take screenshots during a test. Its documented call is $client->takeScreenshot($path). The Symfony guide describes a screenshot of the current page, not a contractual full-document capture. Panther’s implementation starts the client and delegates to the underlying WebDriver’s takeScreenshot() method, so the actual capture behavior may depend on the browser and driver.

As an Amazon Associate I earn from qualifying purchases.

Symfony’s guide shows that screenshot dimensions are affected by the browser window size, including Chrome configured with --window-size=1500,4000 and Firefox resized with WebDriverDimension. This supports the window-resizing approach below, but does not establish that every browser or driver will capture every pixel of a long document that way.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Try the window-resizing workaround

The following PHP example follows a technique reported in Symfony Panther issue #587. It measures the document, resizes the browser window, and then asks Panther to save a screenshot. The issue was opened on February 20, 2023; it is a community report, not an official API guarantee.

<?php

use FacebookWebDriverWebDriverDimension;
use SymfonyComponentPantherClient;

$client = Client::createChromeClient();
$client->request('GET', 'https://example.test/long-page');

$width = $client->executeScript('return document.documentElement.scrollWidth');
$height = $client->executeScript('return document.documentElement.scrollHeight');

$client->manage()->window()->setSize(new WebDriverDimension($width, $height));
$client->takeScreenshot('long-page.png');

Replace https://example.test/long-page with the page under test and ensure the destination directory is writable. This example uses Chrome; it does not demonstrate cross-browser compatibility or establish a maximum supported image size.

Wait for the right page state first

Measure only after the content you need is present. A page may add content asynchronously, load images lazily, or change height after the initial response. Panther supports JavaScript execution and waiting for elements, but there is no universal readiness condition for every site. Use a page-specific condition, such as waiting for a known content element, before reading scrollWidth and scrollHeight. If the page keeps growing after measurement, the saved image may omit later content.

Check the result rather than assuming full-page capture

Open the image and confirm that its width, height, and bottom content match the intended page state. If the result is clipped, blank, or unexpectedly small, treat that as a browser/driver or page-specific limitation and investigate before relying on it in a test pipeline. The available Panther documentation and issue report do not establish reliability limits across browser versions, drivers, or page types.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Browser and driver setup

Panther controls Chrome or Firefox using WebDriver, so the matching browser and driver setup matters. Symfony’s end-to-end testing guide describes ChromeDriver and GeckoDriver installation, including the dbrekelmans/bdi driver-installer option. Follow the current Symfony instructions for your installed Panther version and chosen browser; do not assume a driver setup for one browser applies to the other.

The Symfony package page listed Panther 2.4.0 as the latest version when observed, but package versions change. Check Packagist’s Symfony Panther page for the current release rather than pinning an article’s version number as current.

Troubleshooting

  • The screenshot contains only the visible viewport: The documented Panther method is not specified as guaranteed full-document capture. Confirm that resizing took effect and inspect the output; browser or driver behavior can vary.
  • The bottom of the page is missing: The page may have grown after dimensions were measured. Wait for the relevant content or lazy-loaded elements before measuring, then capture again.
  • The screenshot is blank or navigation did not finish: Make sure the page has reached the state your test requires before running the measurement and screenshot calls. Use an explicit, page-specific wait rather than assuming that navigation alone means all dynamic content is ready.
  • The browser window cannot be resized to the requested dimensions: Check the values returned by the document measurements and the browser/driver setup. Very large pages and browser or driver limits have not been established for this workaround, so reduce the test page or validate another capture method instead of assuming arbitrary dimensions are supported.
  • The screenshot file is absent: Check that the destination path is writable and that the test process has permission to create the file.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you need a screenshot without wiring up Panther and a browser driver, ScreenshotNeo provides a website screenshot API and MCP server. A single GET request can return an image or PDF. For example, this cURL request saves a WebP screenshot of the same long-page URL; see the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.test/long-page -o shot.webp

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be disabled. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up for ScreenshotNeo’s free plan to try up to 1,000 screenshots a month with no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.