Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteSet the browser viewport, not the screenshot file, to control screen size. In PhantomJS, assign page.viewportSize = { width: W, height: H } before page.open(). In CasperJS, pass the same object as viewportSize when creating the Casper instance, or call casper.viewport(W, H) during a flow. Use clipRect only when you need to crop the captured pixels, and use paperSize for PDF page dimensions.
What “screen size” means in these tools
PhantomJS and CasperJS do not resize a physical monitor. They emulate a browser window with a viewport measured in CSS pixels. The viewport width and height determine which responsive breakpoints the page sees, how text and columns reflow, and what content is initially visible.
Three settings are easy to confuse:
- Viewport: the virtual browser area used for layout.
- Clip rectangle: the rectangle copied into an image during capture.
- Paper size: the page dimensions used when rendering a PDF.
Set the viewport explicitly whenever a test or screenshot must be reproducible. CasperJS leaves PhantomJS’s documented default viewport of 400 × 300 pixels unchanged unless you configure it.
Set the viewport in PhantomJS
Initial size before navigation
Assign an object with numeric width and height properties before opening the URL. Setting it before navigation ensures the first layout and any scripts that run during page load see the intended dimensions.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
var page = require('webpage').create();
page.viewportSize = {
width: 1024,
height: 768
};
page.open('https://example.com/', function (status) {
if (status !== 'success') {
console.log('Open failed: ' + status);
phantom.exit(1);
return;
}
page.render('example-1024x768.png');
phantom.exit();
});
The filename extension selects the output format in PhantomJS. For example, a .png file produces PNG output; choose the extension that matches your pipeline.
Reusable dimensions
Keeping dimensions in variables makes it easy to run the same capture at several breakpoints:
var page = require('webpage').create();
var width = 1366;
var height = 768;
page.viewportSize = { width: width, height: height };
page.open('https://example.com/', function (status) {
if (status === 'success') {
page.render('desktop.png');
}
phantom.exit(status === 'success' ? 0 : 1);
});
Use positive integer CSS-pixel values. The viewport is independent of device-pixel-ratio concepts; PhantomJS’s viewport setting alone does not turn a capture into a retina image.
Set the viewport in CasperJS
Configure it when creating Casper
Pass viewportSize to casper.create(). This is the most predictable option when every step in the run should start at the same size.
var casper = require('casper').create({
viewportSize: {
width: 1024,
height: 768
}
});
casper.start('https://example.com/');
casper.then(function () {
this.capture('page-1024x768.png');
});
casper.run(function () {
this.exit();
});
Because CasperJS runs on PhantomJS, this option ultimately configures PhantomJS’s page viewport. Explicit values also avoid accidentally testing the 400 × 300 default.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Change size during a run
Use casper.viewport(width, height) when one workflow must test multiple responsive states or when navigation has already begun.
var casper = require('casper').create();
casper.start('https://example.com/');
casper.viewport(1024, 768).then(function () {
this.capture('wide.png');
});
casper.viewport(375, 812).then(function () {
this.capture('phone.png');
});
casper.run(function () {
this.exit();
});
The callback form is important when later actions depend on the new layout. CasperJS documents the asynchronous continuation so page reflow can finish before the next step:
casper.viewport(375, 812, function () {
this.echo('Viewport changed; continue after reflow.');
this.capture('mobile.png');
});
Prefer the chained .then() form in a larger sequence because it keeps navigation, waits, clicks and captures in CasperJS’s step queue.
Viewport size versus screenshot crop
Changing viewportSize changes page layout; it does not automatically define the rectangle written to an image. PhantomJS’s clipRect selects a capture region separately.
var page = require('webpage').create();
page.viewportSize = { width: 1280, height: 900 };
page.clipRect = { top: 0, left: 0, width: 800, height: 600 };
page.open('https://example.com/', function (status) {
if (status === 'success') {
page.render('cropped.png');
}
phantom.exit();
});
Here the page lays out at 1280 × 900, while the saved image is cropped to 800 × 600. If you want the entire viewport, make the clip rectangle match it, or omit clipRect and let the renderer use its normal capture area.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
PDF output uses paper settings
For PDF generation, set PhantomJS’s paperSize; it defines print-page dimensions rather than the browser viewport. A viewport can still affect responsive layout before printing, so configure both when you need a particular on-screen breakpoint and a particular paper format.
var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };
page.paperSize = {
format: 'A4',
orientation: 'portrait',
margin: '1cm'
};
page.open('https://example.com/', function (status) {
if (status === 'success') {
page.render('page.pdf');
}
phantom.exit(status === 'success' ? 0 : 1);
});
See the PhantomJS paper-size API for the supported paper-size forms. Do not try to obtain an A4 PDF by changing only viewportSize.
Outdated 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 matchWindows 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 reinstallTest responsive layouts systematically
A practical matrix names each viewport and output so failures are attributable to a breakpoint, not an overwritten file:
| Purpose | Width × height (CSS px) | Typical check |
|---|---|---|
| Small phone | 375 × 812 | Navigation menu, wrapping, fixed controls |
| Tablet portrait | 768 × 1024 | Two-column transitions and touch targets |
| Laptop | 1366 × 768 | Primary desktop layout and above-the-fold content |
| Large desktop | 1920 × 1080 | Maximum-width containers and excess whitespace |
These are test choices, not PhantomJS requirements. Select dimensions that match the breakpoints your CSS and users actually need. Keep the height explicit when comparing screenshots, because a taller viewport can reveal lazy content or change sticky-element behavior.
Common problems and fixes
The screenshot is only 400 × 300
Cause: no viewport was configured, and CasperJS did not override PhantomJS’s default. Fix: set viewportSize in casper.create(), or assign page.viewportSize before page.open().
The page still looks like the old breakpoint
Cause: the viewport was changed after a layout-dependent action, or the next step ran before reflow completed. Fix: put casper.viewport() in the step flow and use its callback or a chained continuation before clicking, querying dimensions or capturing.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
The image dimensions do not match the viewport
Cause: clipRect is selecting a different output rectangle. Fix: inspect or remove page.clipRect; set its width and height to the desired crop independently of the viewport.
A full-page capture is cut off
Cause: the viewport controls the visible browser area, but it does not automatically stitch an arbitrarily tall page. Fix: measure the document, set an appropriate capture rectangle or capture in sections, and account for lazy-loaded content before rendering. Verify the result at the exact viewport used by your test.
Navigation fails or renders blank content
Check the callback status, network access, redirects, TLS compatibility and page scripts. Log status and exit with a nonzero code on failure, as in the examples. PhantomJS and CasperJS are legacy projects; their documentation may not reflect modern browser behavior, so verify that your site, JavaScript and runtime versions are compatible before adopting them for new automation.
Reliability and performance practices
- Set one explicit viewport at the start of every run; do not rely on process defaults.
- Use deterministic filenames containing the width and height when generating a matrix.
- Wait for the application state you need, not merely for a fixed delay. A selector-based condition is preferable when your CasperJS flow can express it.
- Keep viewport changes together with the capture or interaction that depends on them, and wait for reflow.
- Separate layout testing from crop testing so a failing image has one clear cause.
- Record the PhantomJS/CasperJS versions and the operating environment. Legacy rendering engines can differ from current Chrome, Firefox and Safari.
Or skip the browser setup
If you only need a dependable website image or PDF, ScreenshotNeo accepts the URL and capture settings through one API call. Its cleanup step accepts cookie-consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup action can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.
For a direct request, see the ScreenshotNeo API documentation:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The same call in 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 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 for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools. It supports viewport and device presets, full-page and element captures, dark mode, retina scale, PDF paper settings, custom CSS or JavaScript, clicks, waits, request blocking, headers, cookies, user agents, authorization, timezone, geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000 per month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing provides two months free, and every feature is available on every plan. You can start with 1,000 free screenshots a month with no card.
FAQ
Can I use decimal viewport dimensions?
Use positive integer CSS-pixel dimensions. Integer values make breakpoints and screenshot comparisons predictable.
Recommended Free Tools
Does viewport width change the PDF paper size?
No. Width and height control web layout; paperSize controls the PDF’s print page.
Should I resize before or after opening a URL in CasperJS?
Configure the initial size in casper.create() when possible. If resizing after navigation, wait on the asynchronous viewport step before layout-dependent work.
Frequently Asked Questions
Is PhantomJS’s 400 × 300 size a screen resolution?
No. It is the documented default browser viewport used when no explicit size is configured.
What controls the pixels saved from a PhantomJS page?
The viewport controls layout, while clipRect independently controls the captured rectangle.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Are PhantomJS and CasperJS suitable for a new browser-compatibility suite?
They are legacy tools, so verify runtime and site compatibility; current-browser automation may be more appropriate for new projects.
The Bottom Line
Set page.viewportSize before PhantomJS navigation or configure CasperJS’s viewportSize; use an asynchronous casper.viewport() step for runtime changes. Keep viewport, crop and PDF paper settings separate so your captures and responsive tests match the dimensions you intended.
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.

