Use a real browser from your Spring Boot application. Spring Boot provides configuration, dependency injection and HTTP endpoints, but it does not render a remote website by itself. Playwright for Java is the clearest implementation for viewport, full-page, element and in-memory screenshots; Selenium WebDriver is a practical alternative when your project already uses Selenium.
The example below keeps the target URL and output path in Spring configuration, launches Chromium, waits for navigation, captures a full-page PNG and closes browser resources safely. Adapt the dependency version and browser installation to your project and deployment image.
What you need before writing code
- A Spring Boot application running on a JDK supported by the Playwright Java version you select.
- A compatible Playwright Java dependency and the browser binaries required by that dependency. Pin versions together and provision the browsers in your build or container image.
- Permission for the process to launch a browser and write the destination file, or enough memory for an in-memory response.
- A policy for which URLs your service may visit. Never turn an unauthenticated screenshot endpoint into an unrestricted server-side request forgery (SSRF) proxy.
No particular Spring Boot release, operating system package set or browser image is universal. Verify those details for your chosen project and runtime.
Choose the capture boundary first
Viewport screenshot
A normal screenshot records the page as currently visible in the browser viewport. Use it for thumbnails, previews and visual checks at a known width and height.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
Full-page screenshot
Set fullPage to true to include the page’s full scrollable height. Very long pages can produce large images and consume substantial memory.
Element screenshot
Use a locator and capture only a matching element, such as a card, header or chart. The locator must resolve to the intended element before capture.
Image bytes instead of a file
Playwright can return a byte[]. This is useful when the controller should stream an image, store it in object storage or send it to a visual-diff system without creating a temporary file.
Configure the target in Spring Boot
Keep deployment-specific values outside Java source. Spring Boot can read properties or YAML, environment variables and command-line arguments; bind them with @ConfigurationProperties or inject individual values with @Value. Later property sources can override earlier ones according to the configuration order for your Boot version.
Free tools Windows power users keep installed
One-click scans. No signup required.
# application.yml
screenshot:
url: https://example.com
output: build/screenshots/example.png
full-page: true
navigation-timeout-ms: 30000
Use environment variables or command-line arguments for production targets rather than committing private URLs or credentials. Validate the URL scheme, hostname allow-list and output location before invoking a browser.
Implement a Playwright screenshot service
Service code
The following flow creates Playwright, launches Chromium, creates an isolated context and page, navigates to the configured URL and writes a PNG. The try-with-resources block closes Playwright; the explicit browser close releases the browser process.
package com.example.screenshot;
import com.microsoft.playwright.Browser;
import com.microsoft.playwright.BrowserContext;
import com.microsoft.playwright.Page;
import com.microsoft.playwright.Playwright;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Service;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@Service
public class ScreenshotService {
private final ScreenshotProperties properties;
public ScreenshotService(ScreenshotProperties properties) {
this.properties = properties;
}
public Path capture() throws Exception {
Path output = Paths.get(properties.output());
Path parent = output.getParent();
if (parent != null) {
Files.createDirectories(parent);
}
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch();
try {
BrowserContext context = browser.newContext();
Page page = context.newPage();
page.setDefaultNavigationTimeout(properties.navigationTimeoutMs());
page.navigate(properties.url());
page.screenshot(new Page.ScreenshotOptions()
.setPath(output)
.setFullPage(properties.fullPage()));
context.close();
return output;
} finally {
browser.close();
}
}
}
}
@ConfigurationProperties(prefix = "screenshot")
record ScreenshotProperties(
String url,
String output,
boolean fullPage,
double navigationTimeoutMs) {
}
Enable configuration-properties scanning in your application (for example, with @ConfigurationPropertiesScan) or register the properties class explicitly. The illustrative record uses a numeric timeout; choose the type and validation rules that fit your Boot version.
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
Expose a minimal endpoint
A command-line runner or scheduled job is safer when captures are internal. If you expose an HTTP endpoint, return a controlled result and avoid accepting arbitrary URLs until you have SSRF protections.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemspackage com.example.screenshot;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import java.nio.file.Files;
@RestController
public class ScreenshotController {
private final ScreenshotService service;
public ScreenshotController(ScreenshotService service) {
this.service = service;
}
@PostMapping(value = "/internal/screenshot", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> capture() throws Exception {
var path = service.capture();
return ResponseEntity.ok("{"file":"" + path.toString().replace("\", "\\") + ""}");
}
}
For a public API, prefer returning an opaque object-storage key rather than a server filesystem path, authenticate the request, rate-limit it and log the target and duration without recording sensitive page contents.
Return a screenshot directly as bytes
Replace the file-writing call with page.screenshot(). The result is a byte[] that can be returned as image/png or passed to another service.
byte[] image = page.screenshot(new Page.ScreenshotOptions()
.setFullPage(true));
return ResponseEntity.ok()
.contentType(MediaType.IMAGE_PNG)
.body(image);
Do not keep unbounded byte arrays for many concurrent requests. Apply a maximum page size, concurrency limit and request timeout.
Capture one element
After navigation, locate the element and capture it. A missing or duplicated selector should be treated as a failed capture rather than silently returning the wrong region.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →page.locator(".header").screenshot(
new Locator.ScreenshotOptions().setPath(Paths.get("header.png"))
);
Dynamic sites may render the element after the initial navigation. Wait for a reliable selector or application-specific readiness signal before taking the image. Avoid arbitrary sleeps unless the page has no better readiness condition.
Options that materially change output
- Format and quality: PNG is lossless; JPEG and WebP can reduce size. Quality settings apply where the selected format supports them.
- Scale: device scale affects pixel dimensions and file size. Keep it fixed when comparing images.
- Viewport: set a deliberate width and height so responsive breakpoints do not change between runs.
- Timeout: use a bounded navigation and action timeout. A timeout should produce a controlled error and cleanup.
- Full page: enable it only when the complete scrollable document is required.
- Animations and fonts: asynchronous fonts, carousels and transitions can change pixels. Disable or wait for them when deterministic output matters.
Exact option names and availability depend on the Playwright Java version you pin. Check that version’s API before copying additional settings.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Navigation and reliability practices
Wait for meaningful readiness
Navigation completion does not guarantee that client-side data, fonts or images have finished rendering. Wait for a selector that represents usable content, or use a carefully chosen network-idle strategy where it is appropriate. Pages that maintain analytics or live connections may never become truly idle.
Control the environment
Use a fixed viewport, timezone, locale and user agent when visual consistency matters. External APIs, advertisements and third-party widgets can still change the result or delay loading.
Manage browser lifetime
Launching a new browser for every request is simple but can be expensive under load. Reuse a controlled browser process only when you can isolate contexts, cap concurrency and recover from a crashed process. Always close pages, contexts and browsers on success, timeout and exception.
Protect the service
- Allow only approved schemes and hosts; block loopback, link-local, private-network and metadata endpoints.
- Set maximum navigation time, response size and screenshot dimensions.
- Run the browser with least privilege and an appropriate sandbox policy for your deployment.
- Do not forward arbitrary request headers or cookies from untrusted callers.
- Record structured errors and durations, but redact URLs that may contain secrets.
Selenium WebDriver alternative
If the application already uses Selenium, use its existing driver rather than adding another browser stack solely for one screenshot. Selenium exposes capture through TakesScreenshot, implemented by WebDriver and related WebElement types.
WebDriver driver = new ChromeDriver();
try {
driver.get(targetUrl);
byte[] png = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.BYTES);
Files.write(Paths.get("screenshot.png"), png);
} finally {
driver.quit();
}
Selenium’s output can be a file or a base64 form through its OutputType API. Whether a capture represents the viewport, whole page or visible frame depends on driver and browser conformance; do not assume every driver provides a full-page image. Existing Selenium users should verify their driver’s behavior for the required boundary.
Troubleshooting common failures
Browser executable not found
Cause: the Java library is present but its browser binaries are absent or unavailable in the runtime image. Fix: install or provision the browser binaries required by the pinned Playwright version and verify the process can execute them.
Recommended Free Tools
Navigation timeout
Cause: the site is slow, blocked, waiting on a resource or never reaches the selected readiness condition. Fix: confirm the URL from the same network, set a bounded but appropriate timeout, wait for a specific selector and handle the failure without leaking the browser.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Blank or incomplete image
Cause: capture occurred before client-side rendering, fonts or lazy images completed. Fix: wait for a content selector, allow required images to load, set a stable viewport and inspect page-console or network errors.
Wrong responsive layout
Cause: viewport, device scale, user agent or locale differs between runs. Fix: set those values explicitly in the browser context and keep them constant for comparisons.
Permission denied writing the file
Cause: the service user cannot create the directory or file. Fix: use a writable configured directory, create parent directories deliberately and check container volume permissions.
Out-of-memory or oversized screenshots
Cause: very tall pages, high device scale or many concurrent captures. Fix: prefer viewport or element captures, lower scale, cap page dimensions and limit concurrency.
Selenium captures only the visible area
Cause: full-page support is driver-dependent. Fix: verify the specific driver, use a documented full-page mechanism for that environment or switch to Playwright’s fullPage option.
Performance, cost and operational planning
No universal speed or capacity figure applies: browser startup, page complexity, network conditions, fonts and concurrency determine the result. Measure your own target pages. Keep a warm, bounded browser pool only after profiling and add health checks to replace crashed instances.
For synchronous HTTP requests, return a clear timeout or accepted-job response rather than holding connections indefinitely. For batch work, queue jobs, persist results and make retries idempotent. Cache only when the page’s freshness requirements permit it; include viewport and relevant configuration in the cache key.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBest Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP or PDF. It accepts the cookie or consent banner like a visitor, then removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status.
Use the API when you do not want browser binaries, lifecycle management and screenshot plumbing inside your Spring service:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo documentation for all options, including full-page capture, CSS selectors, device presets, custom CSS and JavaScript, waits, cookies, headers, geolocation, PDF output, caching, signed links, asynchronous jobs, bulk capture and usage reporting.
The same endpoint works from Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
And from Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Frequently asked questions
Does Spring Boot have a built-in website screenshot API?
No. Spring Boot hosts and configures your application; a browser automation library such as Playwright or Selenium performs the rendering and capture.
Can I capture a page that requires login?
Yes, when your browser context is supplied with an authorized, secure session. Keep credentials out of source code, restrict access to the capture service and avoid exposing session cookies in logs or responses.
Should I choose Playwright or Selenium for a new implementation?
Playwright is the better fit for the examples here because its documented Java API covers viewport, full-page, element and byte-array captures directly. Selenium remains sensible when the project already depends on WebDriver.
Quick Recap
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.

