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
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);
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"])
$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 -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"
}'
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"]
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"])
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());
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
pdf_landscape | boolean | false | Generate PDF in landscape orientation. |
Example: Landscape PDF
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
pdf_page_format | string | A4 | Page size: A3, A4, A5, Letter, Legal, or Tabloid. |
Format dimensions
| Format | Size (mm) | Size (inches) | Best for |
|---|---|---|---|
A3 | 297 × 420 | 11.7 × 16.5 | Wide tables, posters, large dashboards |
A4 | 210 × 297 | 8.3 × 11.7 | Standard documents (international) |
A5 | 148 × 210 | 5.8 × 8.3 | Booklets, flyers |
Letter | 216 × 279 | 8.5 × 11 | Standard documents (US/Canada) |
Legal | 216 × 356 | 8.5 × 14 | Legal documents (US) |
Tabloid | 279 × 432 | 11 × 17 | Oversized prints, spreadsheets |
Example: US Letter format
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.
| Parameter | Type | Default | Description |
|---|---|---|---|
pdf_margin_top | string | 10mm | Top margin. |
pdf_margin_right | string | 10mm | Right margin. |
pdf_margin_bottom | string | 10mm | Bottom margin. |
pdf_margin_left | string | 10mm | Left margin. |
Margins accept CSS units: mm, cm, in, px. Set to 0 for edge-to-edge content.
Example: Professional report with wide margins
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.
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.
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
widthparameter 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 printoverrides. - If the PDF has too many pages, try a wider viewport (
width=1400) to reduce content wrapping and make the page shorter.
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.