Features Full Page Screenshot Wait for Selector & Delay Block Cookie Banners Custom Viewport & Device Website to PDF HTML to Image Dark Mode Image Format & Quality MCP Server Webhook Pricing Docs Blog Log In Sign Up

PDF Rendering

When you need a document rather than an image, set the output format to PDF. Unlike image screenshots, PDFs contain vector text that stays sharp at any zoom level, making them perfect for reports, invoices, legal documents, and anything meant to be printed or archived.

Basic PDF capture

Set format to pdf and the API generates a PDF document instead of an image. The page is rendered just like a regular screenshot, then converted to a paginated PDF.

Example: Simple PDF

JavaScript
const response = await fetch('https://api.screenshotrun.com/v1/screenshots', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    url: 'https://example.com/report',
    format: 'pdf',
  }),
});

const { data } = await response.json();
console.log(data.links.image);
Python
import requests

response = requests.post(
    "https://api.screenshotrun.com/v1/screenshots",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "url": "https://example.com/report",
        "format": "pdf",
    },
)

data = response.json()["data"]
print(data["links"]["image"])
PHP
$response = Http::withToken('YOUR_API_KEY')
    ->post('https://api.screenshotrun.com/v1/screenshots', [
        'url' => 'https://example.com/report',
        'format' => 'pdf',
    ]);

$data = $response->json('data');
cURL
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/report",
    "format": "pdf"
  }'
Ruby
require "net/http"
require "json"

uri = URI("https://api.screenshotrun.com/v1/screenshots")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer YOUR_API_KEY"
request["Content-Type"] = "application/json"
request.body = {
  url: "https://example.com/report",
  format: "pdf",
}.to_json

response = http.request(request)
data = JSON.parse(response.body)["data"]
Go
body, _ := json.Marshal(map[string]any{
        "url": "https://example.com/report",
        "format": "pdf",
    })

req, _ := http.NewRequest("POST",
    "https://api.screenshotrun.com/v1/screenshots",
    bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")

resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()

var result map[string]any
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["data"])
Java
var client = HttpClient.newHttpClient();

var body = """
    {
        "url": "https://example.com/report",
        "format": "pdf"
    }
    """;

var request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.screenshotrun.com/v1/screenshots"))
    .header("Authorization", "Bearer YOUR_API_KEY")
    .header("Content-Type", "application/json")
    .POST(HttpRequest.BodyPublishers.ofString(body))
    .build();

var response = client.send(
    request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Note

PDF output always captures the full page content — the full_page parameter is implied. The resize_width, resize_height, and omit_background parameters have no effect on PDF output since they apply to images only.

Page orientation

By default, PDFs are generated in portrait orientation (taller than wide). Switch to landscape when your content is wider than it is tall — data tables, dashboards, timelines, or spreadsheets.

ParameterTypeDefaultDescription
pdf_landscapebooleanfalseGenerate PDF in landscape orientation.

Example: Landscape PDF

bash
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/dashboard",
    "format": "pdf",
    "pdf_landscape": true
  }'

Page size

The pdf_page_format parameter controls the physical page size of the PDF. Choose the format that matches your printing or distribution needs.

ParameterTypeDefaultDescription
pdf_page_formatstringA4Page size: A3, A4, A5, Letter, Legal, or Tabloid.

Format dimensions

FormatSize (mm)Size (inches)Best for
A3297 × 42011.7 × 16.5Wide tables, posters, large dashboards
A4210 × 2978.3 × 11.7Standard documents (international)
A5148 × 2105.8 × 8.3Booklets, flyers
Letter216 × 2798.5 × 11Standard documents (US/Canada)
Legal216 × 3568.5 × 14Legal documents (US)
Tabloid279 × 43211 × 17Oversized prints, spreadsheets

Example: US Letter format

bash
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/invoice",
    "format": "pdf",
    "pdf_page_format": "Letter"
  }'

Margins

Control the white space around the content on each page. By default, all margins are set to 10mm.

ParameterTypeDefaultDescription
pdf_margin_topstring10mmTop margin.
pdf_margin_rightstring10mmRight margin.
pdf_margin_bottomstring10mmBottom margin.
pdf_margin_leftstring10mmLeft margin.

Margins accept CSS units: mm, cm, in, px. Set to 0 for edge-to-edge content.

Example: Professional report with wide margins

bash
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/report",
    "format": "pdf",
    "pdf_page_format": "A4",
    "pdf_margin_top": "25mm",
    "pdf_margin_bottom": "25mm",
    "pdf_margin_left": "20mm",
    "pdf_margin_right": "20mm"
  }'

Example: Edge-to-edge capture

Zero margins capture the page content right to the edge — useful for screenshots that happen to need PDF format rather than traditional document output.

bash
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com",
    "format": "pdf",
    "pdf_margin_top": "0",
    "pdf_margin_right": "0",
    "pdf_margin_bottom": "0",
    "pdf_margin_left": "0"
  }'

Combining PDF options

Landscape dashboard report on A3

A3 in landscape gives you plenty of room for wide data tables and dashboard panels.

bash
curl -X POST https://api.screenshotrun.com/v1/screenshots \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/analytics",
    "format": "pdf",
    "pdf_landscape": true,
    "pdf_page_format": "A3",
    "pdf_margin_top": "15mm",
    "pdf_margin_bottom": "15mm",
    "pdf_margin_left": "10mm",
    "pdf_margin_right": "10mm"
  }'

Tips

  • The width parameter still affects how the page renders inside the PDF. A wider viewport means the page layout spreads out, which can change how content flows across PDF pages.
  • Use CSS injection to apply print-friendly styles: hide navigation, adjust colors for printing, or add CSS @media print overrides.
  • If the PDF has too many pages, try a wider viewport (width=1400) to reduce content wrapping and make the page shorter.
Tip

Many websites already have @media print styles that optimize the layout for printing. These styles are automatically applied when generating PDFs, so the output may already look cleaner than the regular page view.