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

Use page.render() without setting clipRect. PhantomJS then renders the entire page, while viewportSize controls the responsive layout used during rendering. The script below checks that the page loaded before saving a PNG and exits cleanly. PhantomJS is a legacy choice: its project homepage says, “Important: PhantomJS development is suspended until further notice.”

Quick answer: render without clipRect

In PhantomJS, page.render('full-page.png') processes the whole page when no clipping rectangle is configured. Do not confuse this with the viewport. page.viewportSize determines the browser’s layout width and height—important for responsive breakpoints—but it does not limit the rendered page to those dimensions.

Save the following as full-page.js:

var page = require('webpage').create();

// Choose the responsive layout you want to capture.
page.viewportSize = {
  width: 1024,
  height: 768
};

page.open('https://example.com/', function (status) {
  if (status !== 'success') {
    console.log('Unable to load the address!');
    phantom.exit(1);
    return;
  }

  // No clipRect: render the entire document.
  page.render('full-page.png');
  phantom.exit();
});

Run it with:

phantomjs full-page.js

On a successful load, the output file is written in the current directory. The filename extension selects the output format; the example creates a PNG.

What each setting does

page.open() loads the target

page.open(url, callback) invokes the callback with a status such as success. Render only after a successful status. A failed status can mean a DNS problem, refused connection, TLS issue, redirect failure, or another load error. Rendering after failure can produce an empty or misleading file.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • 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.

viewportSize controls layout

Set the viewport before calling page.open(). A width of 1024 pixels, for example, causes media queries and responsive components to lay out as they would in a 1024-pixel-wide browser window. Include both width and height; PhantomJS documents viewport height as required.

Changing the viewport changes the page’s layout, not the fact that the render is full-page. If you need a mobile layout, use a mobile-sized viewport and leave clipRect unset.

page.render() writes the file

The render method saves the page to the supplied filename. PNG, JPEG, BMP, PPM and PDF are documented formats, with GIF available where the Qt build supports it. The extension normally determines the format.

clipRect limits the capture

A clipping rectangle has top, left, width and height values. Once set, only that rectangle is rasterized. That is useful for a hero area, chart or viewport-sized image, but it is the wrong setting for a full-page screenshot. Remove the property entirely for the documented full-page behavior.

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

A bounded screenshot versus a full-page screenshot

Goal Viewport clipRect Result
Entire document Set the desired responsive width and height Leave unset PhantomJS processes the full page
Viewport-sized image Set the browser dimensions Set a rectangle matching the desired region Only the rectangle is rendered
Specific component Choose a layout that displays the component Set coordinates around that component A cropped region of the page

The rectangle’s coordinates are page coordinates, not CSS selectors. PhantomJS’s documented API does not make an unset viewport height equivalent to “capture everything”; specify both viewport dimensions and omit only the clipping rectangle.

Make dynamic pages ready before rendering

A successful page.open() callback means the navigation completed according to PhantomJS, not that every image, animation, lazy-loaded section or later JavaScript request has finished. The official examples include a 200 ms delay in one situation, but that sample delay is not a universal guarantee.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 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.

Use a site-specific readiness condition

If you control the page, expose a marker after the content needed for the screenshot is ready. You can poll for that marker, then render:

var page = require('webpage').create();
page.viewportSize = { width: 1024, height: 768 };

var url = 'https://example.com/report';
var deadline = Date.now() + 15000;

function captureWhenReady() {
  var ready = page.evaluate(function () {
    return document.documentElement.getAttribute('data-screenshot-ready') === 'true';
  });

  if (ready) {
    page.render('report-full.png');
    phantom.exit(0);
    return;
  }

  if (Date.now() >= deadline) {
    console.log('Timed out waiting for the page readiness marker.');
    phantom.exit(2);
    return;
  }

  window.setTimeout(captureWhenReady, 100);
}

page.open(url, function (status) {
  if (status !== 'success') {
    console.log('Unable to load the address!');
    phantom.exit(1);
    return;
  }
  captureWhenReady();
});

The page would need to set data-screenshot-ready="true" when its own data and images are ready. For a site you do not control, choose a condition that is specific to that site—for example, the presence of a result container—and set a maximum wait so a broken page cannot leave the process running forever. A fixed sleep can still be useful as a small site-specific buffer, but it should not be treated as proof that asynchronous work has completed.

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

Wait for a known element

You can test for an element from the page context and render when it appears:

function waitForSelector(selector, done) {
  var end = Date.now() + 10000;

  (function poll() {
    var present = page.evaluate(function (s) {
      return !!document.querySelector(s);
    }, selector);

    if (present) {
      done(true);
      return;
    }
    if (Date.now() >= end) {
      done(false);
      return;
    }
    window.setTimeout(poll, 100);
  }());
}

waitForSelector('#main-content', function (found) {
  if (!found) {
    console.log('The expected content did not appear.');
    phantom.exit(2);
    return;
  }
  page.render('full-page.png');
  phantom.exit(0);
});

Place this call inside the successful page.open() callback. Selectors and time limits must match the application; PhantomJS documentation does not define one all-purpose “network idle” condition.

Choosing PNG, JPEG or PDF

PNG

Use a .png filename for a lossless raster screenshot. It is a practical default for text, interfaces and diagrams. The documented quality parameter affects encoding; PNG compression can change file size without changing the image’s visual content.

JPEG

Use .jpg or .jpeg when a smaller, lossy image is acceptable. JPEG quality is an integer from 0 to 100. Lower values generally produce smaller files with more compression artifacts. Confirm the exact behavior in the PhantomJS build you operate because this is legacy software.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • 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

PDF is documented as an output format, but it is a document-style result rather than a conventional pixel screenshot. Use it when pagination and printable output matter more than one continuous raster image.

// Examples; keep the same successful page.open callback.
page.render('page.png');
page.render('page.jpg');
page.render('page.pdf');

Common failures and fixes

The file is only viewport-sized

Look for a clipRect assignment. Remove it for a full-page render. Keep viewportSize if you need a particular responsive layout; it does not need to match the document’s total height.

The output is blank or incomplete

Check the status passed to page.open() and render only on success. Then identify whether the page fills content asynchronously. Add a page-specific readiness check, verify that the expected selector appears, and impose a timeout. A short delay alone may miss lazy images or later requests.

The script never exits

Call phantom.exit() on every success and failure path. The PhantomJS Quick Start warns that the process will not terminate if that call is omitted. Use a nonzero exit code for operational failures so a scheduler can detect them.

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

The page uses a modern JavaScript feature

PhantomJS uses QtWebKit and is no longer being developed. Its homepage explicitly says development is suspended until further notice. Current frameworks, TLS configurations, browser APIs and operating systems may therefore fail or render differently. Do not infer present-day compatibility from a script that worked for an older site; test the exact URL and PhantomJS build you deploy.

Images or fonts are missing

Determine whether they are lazy-loaded, blocked by the page, dependent on later JavaScript, or unavailable to the PhantomJS runtime. Wait for a page-owned readiness marker where possible. If the resource requires authentication, configure the page for that test environment rather than assuming a delay will fix an authorization failure.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • 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 result has the wrong responsive layout

Set page.viewportSize before navigation and include both dimensions. A desktop-width viewport can intentionally produce a desktop layout even when the script runs on a small server. Conversely, a narrow width can trigger mobile breakpoints and change the page’s total height.

A format is rejected

Use a documented extension such as .png, .jpg or .pdf. GIF support depends on the Qt build. Verify the capabilities of the particular PhantomJS binary instead of assuming every format is available everywhere.

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

Operational guidance for repeatable captures

Keep the capture deterministic

  • Set the viewport explicitly rather than relying on a machine default.
  • Use a stable test URL and a page-specific readiness signal.
  • Disable or account for animations when you control the page.
  • Give every wait loop a deadline and return a meaningful exit code.
  • Record the URL, viewport, output format and PhantomJS version alongside the artifact.

Plan for resource use

A full-page image can be much taller and larger than a viewport capture. Choose PNG when fidelity matters and JPEG when lossy compression is acceptable. For very long documents, consider whether PDF or a sequence of bounded captures better fits downstream storage and review; PhantomJS’s full-page behavior does not eliminate the memory required to rasterize a large page.

Treat PhantomJS as legacy infrastructure

The project’s suspended-development notice is a reliability constraint. Pin the binary and operating environment that your existing workflow has validated, keep a representative URL test set, and expect that a site redesign or certificate change may require migration to a maintained browser automation stack. The procedure above describes PhantomJS’s documented behavior; it is not a promise of compatibility with today’s web.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns a PNG, JPEG, WebP or PDF, with full-page capture and controls for viewport, device presets, retina scale, waiting, custom CSS and JavaScript, cookies and headers, authentication, geolocation, blocking, element capture and more. It removes cookie-consent banners, newsletter popups and chat widgets before capture. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the page verdict and billing status in headers.

See the ScreenshotNeo API documentation for parameter details. A direct cURL request is:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 capture 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,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

And in 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}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

ScreenshotNeo includes 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 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Other listed plans are Growth ($15 for 15,000), Pro ($39 for 60,000), Scale ($99 for 250,000) and Business ($249 for 1,000,000); yearly billing provides two months free, and every feature is included on every plan.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 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.

Create a free ScreenshotNeo account to try the API with 1,000 screenshots a month and no card.

Frequently Asked Questions

Does PhantomJS automatically discover the page’s total height?

The documented behavior is that page.render() processes the entire page when no clipRect is set. The viewport still controls layout, and very dynamic pages may need a readiness check before rendering.

Can I use a CSS selector instead of coordinates for PhantomJS cropping?

The documented clipRect API uses numeric top, left, width and height values. To crop an element, calculate its page coordinates in script and assign those values.

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.

Why does a 200-millisecond wait sometimes fail?

The documentation presents 200 milliseconds as an example delay, not a guarantee. Lazy images, animations and later network requests can take longer, so wait for a condition specific to the page and enforce a maximum timeout.

What should replace PhantomJS for a new project?

This workflow is legacy because PhantomJS development is suspended. If you need a maintained browser stack, evaluate a current automation tool separately; if you want an API without managing a browser, ScreenshotNeo is an available alternative.

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.