Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Choose the output first: aShot creates a tall, stitched screenshot image by capturing successive browser viewports. Selenium’s PrintsPage API creates a paginated PDF using the browser’s print layout. They are complementary workflows, not two names for the same operation. Use aShot when you need one visual image of the complete page; use Selenium printing when you need a document with paper size, margins, page breaks and selectable text.
What each Selenium Java workflow actually produces
aShot is a WebDriver screenshot utility. Its viewportPasting strategy scrolls through the page, captures each viewport and pastes the images into one taller bitmap. The result is a Screenshot object containing an image and comparison data. The aShot documentation describes image capture; it does not document PDF encoding or export.
Selenium page printing is a browser print operation. Selenium exposes it through PrintsPage.print(PrintOptions), and ChromeDriver implements that interface. The returned PDF follows print pagination rather than becoming one infinitely tall raster image. Chromium printing is documented as requiring headless mode, so configure Chrome accordingly when running automated jobs.
| Requirement | aShot viewport pasting | Selenium page printing |
|---|---|---|
| Output | One tall PNG/JPEG-style image | Paginated PDF |
| Capture method | Repeated viewport captures, then stitching | Browser print operation with PrintOptions |
| Layout controls | Viewport and image handling | Orientation, page range, paper size, margins, scale and background |
| Main risks | Stitch seams, sticky elements, changing content and device-pixel ratio | Unexpected page breaks, print CSS and Chromium headless requirements |
| Best fit | Visual regression evidence or a complete-page image | Sharing, archiving or printing a document |
Prerequisites and project setup
- Java and a Selenium-compatible WebDriver, such as ChromeDriver, available to your test or build environment.
- A browser version compatible with the driver. Keep the browser, driver and Selenium library aligned.
- A page URL that the test is allowed to access, plus any required authentication or test data.
- A build tool. The aShot README shows Maven coordinates
ru.yandex.qatools.ashot:ashot:1.5.4. Treat 1.5.4 as the README example, not as proof of the newest release: the repository page lists 1.5.2 as its latest release dated December 9, 2015. Verify compatibility with your current Selenium and browser before standardizing on that dependency.
For aShot, add the README dependency to your Maven project and confirm that your dependency tree resolves a compatible Selenium version. Selenium itself is sufficient for the PDF path; aShot is not involved in PDF generation.
#1 Best Overall
Capture a full-page image with aShot
Runnable Java example
import java.io.File;
import javax.imageio.ImageIO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import ru.yandex.qatools.ashot.AShot;
import ru.yandex.qatools.ashot.Screenshot;
import ru.yandex.qatools.ashot.shooting.ShootingStrategies;
public class FullPageAShot {
public static void main(String[] args) throws Exception {
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new", "--window-size=1440,900");
WebDriver driver = new ChromeDriver(options);
try {
driver.get("https://example.com/long-page");
// Replace this with an explicit wait for your page's ready state or key element.
Thread.sleep(1500);
Screenshot screenshot = new AShot()
.shootingStrategy(ShootingStrategies.viewportPasting(100))
.takeScreenshot(driver);
ImageIO.write(screenshot.getImage(), "PNG", new File("full-page.png"));
} finally {
driver.quit();
}
}
}
The 100 argument is the README example’s scroll timeout in milliseconds. It is not a universal optimum: increase it when scrolling triggers expensive rendering, or replace the fixed sleep before capture with an explicit wait for a page-specific condition. The strategy captures the visible viewport repeatedly, so the browser window and page state directly affect the final dimensions.
Make the capture deterministic
- Set a known window size and, if relevant, a consistent browser zoom and display scale.
- Navigate to the page and wait for the content that matters to be present. For single-page applications, wait for a stable application element rather than only the initial DOM load.
- Trigger or observe lazy-loaded content before taking the final image. A page can look complete at the top while images lower down have not loaded.
- Disable or freeze animations where your test permits it. Moving carousels, ads and timestamps can create visible changes between viewport captures.
- Inspect the resulting PNG for horizontal seams, duplicated sticky headers, missing images and abrupt changes in layout.
aShot’s scroll-and-paste mechanism cannot guarantee correct output for every dynamic page. A fixed header may be captured in every viewport and appear repeatedly; an element that changes position while scrolling can leave seams. If visual fidelity is critical, compare captures in the same browser, viewport and display-scale configuration.
Handle high-DPI and sticky-element problems
Device-pixel ratio
A 2017 project issue reported a top-left-only result in a device-pixel-ratio-2 environment. The project owner associated that report with DPR 2 and pointed to viewportRetina. This is a historical, version- and environment-specific report, not a guarantee that one setting fixes every current browser combination. If output dimensions are unexpectedly doubled, cropped or limited to a corner, record the browser, driver, operating system, window size and DPR, then test a retina-aware strategy and a standard strategy.
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
Sticky and fixed-position elements
Before capture, identify headers, consent bars, chat launchers and floating buttons that remain fixed while the page scrolls. Hide them with page-specific CSS or JavaScript only when removing them is acceptable to your evidence requirements. Otherwise, expect them to be present in multiple stitched segments and inspect the image for repetition. Shutterbug’s documentation describes a DevTools-based full-page mode and recommends that approach over its own scroll strategy for sticky elements; that recommendation belongs to Shutterbug and should not be assumed to be an aShot feature.
Generate a paginated PDF with Selenium
Runnable ChromeDriver example
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
import org.openqa.selenium.Pdf;
import org.openqa.selenium.PrintsPage;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.print.PrintOptions;
public class FullPagePdf {
public static void main(String[] args) throws Exception {
ChromeOptions chrome = new ChromeOptions();
chrome.addArguments("--headless=new", "--window-size=1440,900");
WebDriver driver = new ChromeDriver(chrome);
try {
driver.get("https://example.com/long-page");
Thread.sleep(1500); // Prefer an explicit wait in production.
PrintOptions print = new PrintOptions();
print.setOrientation(PrintOptions.Orientation.PORTRAIT);
print.setPageSize(PrintOptions.PageSize.A4);
print.setBackground(true);
print.setScale(1.0);
print.setMarginTop(0.4);
print.setMarginBottom(0.4);
print.setMarginLeft(0.4);
print.setMarginRight(0.4);
// Optional examples:
// print.setPageRanges("1-3");
Pdf pdf = ((PrintsPage) driver).print(print);
byte[] bytes = Base64.getDecoder().decode(pdf.getContent());
Files.write(Path.of("page.pdf"), bytes);
} finally {
driver.quit();
}
}
}
The important call is ((PrintsPage) driver).print(print). The PDF content is returned by Selenium’s PDF API and is written to disk after Base64 decoding. Check the exact method signatures supplied by the Selenium version in your build; APIs evolve, and your IDE will identify any naming differences.
Control the printed layout
- Orientation: portrait suits text-heavy pages; landscape can prevent wide tables from being compressed.
- Paper size: choose the paper format your readers or archive require, such as A4.
- Margins: reduce or increase them to preserve headers, footers and readable line lengths.
- Background: enable background graphics when color blocks or images are part of the evidence.
- Scale: use it to fit wide content, then inspect text size and page breaks.
- Page ranges: print only selected pages when a full document is unnecessary.
Printing honors the browser’s print layout and print-oriented CSS. It is therefore normal for a long page to become several PDF pages, for backgrounds to differ from the screen, or for a section to move because of a page break. Review the generated PDF rather than assuming that a visually correct browser window implies a correct print result.
Choosing and validating the result
Use aShot when
- You need a single image for visual comparison, issue evidence or a design review.
- The exact on-screen appearance matters more than selectable text or paper pagination.
- Your downstream system accepts PNG or another raster image.
Use Selenium printing when
- You need a portable document for sharing or archiving.
- Page size, margins, orientation and page ranges are requirements.
- Selectable text and browser print CSS are preferable to one very tall bitmap.
Validate both in CI
Store the browser and driver versions with each artifact. Check that the file exists and is non-empty, then perform a visual or structural review appropriate to the output. For aShot, check total image dimensions and seams. For PDFs, check page count, clipping, blank pages, missing backgrounds and readable scale. A successful WebDriver command only proves that the browser returned data; it does not prove that dynamic content finished rendering.
Rank #3
Troubleshooting common failures
Only the viewport is captured
Some WebDrivers capture only the viewport. Confirm that the aShot strategy is explicitly viewportPasting, use a compatible driver and inspect the page for content that appears only after scrolling. If the page is inside a scrollable element rather than the document, aShot’s document scrolling may not represent that element; capture the component separately or use a browser-native DevTools approach.
Repeated headers or visible seams
Fixed-position elements and animations are changing between segments. Hide or freeze those elements where appropriate, increase the viewport-pasting delay, wait for fonts and images, and compare captures at a stable DPR.
Images lower on the page are blank
Lazy loading has not completed. Scroll the page deliberately before capture, wait for the image elements or their network-driven state, and ensure that your test data does not expire while the capture runs.
Rank #4
PDF printing throws an unsupported-operation error
The active driver does not implement PrintsPage, or the browser is not running in the mode required by Chromium printing. Use a driver that implements the interface, run Chromium headless, and verify Selenium/driver compatibility.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →PDF pages are clipped or unexpectedly numerous
Inspect print margins, scale, paper size and print CSS. Wide elements may force scaling or overflow; explicit page ranges can hide the problem by omitting affected pages, so first generate the complete document and correct its layout.
The PDF has no colors or backgrounds
Enable background output in PrintOptions and check the site’s print stylesheet. Some pages intentionally remove decorative backgrounds for printing.
Best Value
Or skip the browser setup
ScreenshotNeo provides a website screenshot API and MCP server when you need a clean capture without maintaining WebDriver code. A single request can return 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 before the capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients.
See the ScreenshotNeo API documentation for all options, including full-page lazy-image loading, CSS-selector element capture, dark mode, device presets, retina scale, PDF paper settings and page ranges, custom CSS or JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, selectable cache TTLs, signed links, asynchronous webhooks, bulk capture and usage reporting.
Recommended Free Tools
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan. Create a free ScreenshotNeo account to try the API.
Frequently Asked Questions
Does aShot create a PDF file?
No. aShot’s documented workflow returns a screenshot image. Use Selenium’s PrintsPage and PrintOptions APIs for a PDF.
Can I make the Selenium PDF one infinitely tall page?
Selenium printing is paginated browser print output. Select paper size, margins, scale and page ranges instead of expecting a single tall raster page.
Why does my full-page image differ between machines?
Viewport size, browser and driver versions, device-pixel ratio, fonts, animation timing and lazy-loaded content all affect stitched captures.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallQuick 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.

