How to capture a full-page website screenshot with PDFShift
Use PDFShift’s documented 1280xauto format to render a webpage as a full-height PDF, with runnable Python, cURL, and Node.js examples.
PDFShift’s documented way to capture a webpage at full height is to convert it to a PDF: send the page URL in source to https://api.pdfshift.io/v3/convert/pdf and set format to a width and automatic height, such as 1280xauto. PDFShift calculates the height from the page content. This produces a PDF, not a verified PNG or JPEG screenshot recipe. PDFShift’s guide documents the workflow.
What this method captures
A full-height PDF can preserve the rendered page as a single tall document. In PDFShift’s example, the requested width is 1280 pixels and auto lets the service derive the height from the page content. The width is a starting point, not a universal best setting: the resulting page dimensions and visual scale depend on the source page and chosen width.
PDFShift also describes website screenshots and customizable image output, but the available documentation used for this guide does not specify a screenshot endpoint, exact image format values, or how to handle an image response. Do not send the PDF example expecting a PNG or JPEG. For an image capture, consult the current PDFShift screenshot documentation before choosing an endpoint or parameters.
Python: create a full-height PDF
Install the dependency with python -m pip install requests. Save this as capture.py, set your API key, and run python capture.py.
import requests
api_key = "YOUR_PDFSHIFT_API_KEY"
payload = {
"source": "https://www.example.com",
"format": "1280xauto",
}
response = requests.post(
"https://api.pdfshift.io/v3/convert/pdf",
headers={"X-API-Key": api_key},
json=payload,
timeout=90,
)
response.raise_for_status()
with open("result.pdf", "wb") as output:
output.write(response.content)
Keep the key out of source control and logs. For a production script, load it from an environment variable and report HTTP failures without printing the credential. The timeout in this example is a client-side limit; adjust it to suit your application and the pages you need to render.
cURL: send the conversion request
This request sends the same JSON payload and writes the response body to a PDF file. Replace the placeholder key and target URL.
curl --fail --show-error --silent \
-X POST "https://api.pdfshift.io/v3/convert/pdf" \
-H "X-API-Key: YOUR_PDFSHIFT_API_KEY" \
-H "Content-Type: application/json" \
--data '{"source":"https://www.example.com","format":"1280xauto"}' \
-o result.pdf
--fail makes cURL return an error for an HTTP failure instead of quietly treating an error response as a successful file download. If the request fails, inspect the HTTP status and response details rather than assuming the saved file is a valid PDF.
Node.js: save the PDF response
With Node.js 18 or later, use the built-in fetch API. Save as capture.mjs, set the key in the environment, then run PDFSHIFT_API_KEY=YOUR_PDFSHIFT_API_KEY node capture.mjs.
import { writeFile } from "node:fs/promises";
const apiKey = process.env.PDFSHIFT_API_KEY;
if (!apiKey) {
throw new Error("Set PDFSHIFT_API_KEY before running this script");
}
const response = await fetch("https://api.pdfshift.io/v3/convert/pdf", {
method: "POST",
headers: {
"X-API-Key": apiKey,
"Content-Type": "application/json",
},
body: JSON.stringify({
source: "https://www.example.com",
format: "1280xauto",
}),
signal: AbortSignal.timeout(90_000),
});
if (!response.ok) {
const detail = await response.text();
throw new Error(`PDFShift returned HTTP ${response.status}: ${detail}`);
}
const bytes = Buffer.from(await response.arrayBuffer());
await writeFile("result.pdf", bytes);
Choosing the output dimensions
PDFShift documents custom dimensions in the form {width}x{height}, with pixels as the default unit. It also says dimensions can use units such as cm, mm, in, and pt. For a content-derived height, the documented example is 1280xauto.
- Set a suitable width. A narrower or wider rendering can change line wrapping and therefore the final page height. Pick a width that resembles the layout you want to preserve, then inspect the PDF.
- Use automatic height for a single tall page. This follows the guide’s full-page example. The output may be very long for pages with extensive content.
- Check the resulting document. Confirm that the page is readable and that the content you care about appears. Do not assume every site renders the same way as it appears in your browser.
- Do not infer image settings from PDF settings. The documented
formatexample is for PDF conversion. It does not establish image endpoint parameters or formats.
Page behavior and edge cases
A conversion renders a web page, so the page’s own behavior affects what appears in the document. These are practical checks for interpreting a result; the cited guide does not promise special handling for each case.
- Dynamic content: content that appears only after client-side scripts run may affect what is captured. If a section is missing, confirm it is visible in the public page and review PDFShift’s current options for controlling page rendering.
- Lazy-loaded content: some pages load images or sections only as the visitor scrolls. Inspect the PDF for missing lower-page content and check current provider documentation if the page depends on scrolling to load it.
- Authentication and access restrictions: a URL that requires a logged-in session or is blocked from external requests may not render like your local browser view. Use provider-documented authentication or request options if available; do not assume the basic
sourceexample carries your browser session. - Very long pages: an automatic content height can create a long document. Consider whether a single tall page is useful for reading, printing, or downstream processing.
- Responsive layouts: the specified width influences the layout. If a page is designed for a different viewport, its columns, text wrapping, and height may differ.
Performance, reliability, and cost
The conversion requires a network request and the remote renderer to load the target page. The guide does not provide latency benchmarks, reliability figures, or pricing details, so estimate those from your own workload and PDFShift’s current plan documentation.
- Set a request timeout in your client so a stalled conversion does not hold a worker indefinitely. Choose a limit based on your workload.
- Handle errors before writing output. Check the HTTP response, then save its bytes. This avoids treating an error response as a PDF.
- Retry selectively. A transient network failure may justify a bounded retry with backoff. A persistent invalid URL, inaccessible page, or malformed request needs correction, not repeated retries.
- Measure representative pages. Page complexity and length vary. Track request duration and failure rates in your own environment rather than relying on a generic benchmark.
- Check current pricing and limits with PDFShift before building a high-volume workflow. This research does not establish a per-conversion price or quota.
Troubleshooting
| Symptom | Likely cause | What to check |
|---|---|---|
| HTTP error from the conversion request | Invalid credentials, request data, or a provider-side rejection | Confirm the API key is set in X-API-Key, the JSON is valid, and source is a complete URL. Read the response status and error details. |
| The output file is not a readable PDF | An error response was saved as if it were a successful document | Check the HTTP status before writing bytes. With cURL, use --fail; in Python, call raise_for_status(); in Node.js, check response.ok. |
| The page is cut off or lower content is missing | The page may load content dynamically or on scroll, or the conversion may not reflect the expected layout | Open the public page, verify the content and its loading behavior, and inspect the generated PDF. Consult current PDFShift options for render timing or page behavior. |
| The layout is too narrow, too wide, or wraps differently | The chosen rendering width differs from the layout you need | Adjust the width in format, regenerate, and compare readability and page height. |
| The request times out | The target page or conversion took longer than the client limit | Check that the URL is reachable, choose a suitable client timeout, and retry only transient failures with a bounded policy. |
| You expected a PNG or JPEG | The documented endpoint and example here produce a PDF | Use the current PDFShift screenshot documentation for the image-specific endpoint and response handling. Do not treat 1280xauto as a verified image recipe. |
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server. One GET request can return a screenshot as PNG, JPEG, or WebP, or a PDF. Its documentation is at screenshotneo.com/docs.
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}`);
Cookie banners are accepted like a visitor would accept them, then known consent platforms, newsletter popups, and chat widgets are removed before the shot. Bot checks, blank pages, failed loads, timeouts, and cache hits are never billed, and response headers report the page verdict and billing status. An MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.
Sign up free for 1,000 screenshots a month, with no card required.
FAQ
Does this PDFShift example create a full-page image?
No. It creates a full-height PDF using the documented PDF conversion endpoint. The research available for this guide does not verify the image endpoint or its parameters.
What does 1280xauto mean?
It requests a 1280-pixel-wide rendering with the height derived from the page content, as described in PDFShift’s guide.
Can I use dimensions in physical units?
PDFShift’s guide says custom dimensions may use pixels by default or units including centimeters, millimeters, inches, and points. Confirm the exact syntax in the current guide when using a non-pixel unit.
Where should I check current API details and pricing?
Use PDFShift’s current documentation and plan information. The documented workflow here does not establish current pricing, quotas, or image-capture parameters.


