🚀 Experience the new and improved APIVoid! Check out what's new

URL to PDF API: Convert a URL into a printable PDF file

A JSON API to convert a URL or web page into a printable PDF document. Use this API to convert a URL to high-quality PDF file, you can set PDF paper size and format (A1, A4, etc) and also "fit" the web page into a one PDF page.

Consumes 20 credits per API call

# Example Curl request from the command line:
                          
curl -X POST "https://api.apivoid.com/v2/url-to-pdf" \
     -H "Content-Type: application/json" \
     -H "X-API-Key: YOUR_API_KEY_HERE" \
     -d '{"url":"https://apple.com/"}'

# Example JSON output for a 200 HTTP status code:

{
    "url": "https://apple.com/",
    "rendered_file": {
        "format": "PDF",
        "date_time_utc": "2024-11-29 19:00:32",
        "base64_file": "iVBORw0KGgoAAAANSUhEUgAAB4AAAAQ4CAIAAABnsVYUAAAAAXNSR0IArs4c6QAAIABJREFUeJzs3XdUFNfbB/C7dJbeu4ICQUERBLEgWLA37KKoEbFrrKiINbH3rlhQsWHABhqxgQiKCg...",
        "file_size_readable": "344.53 KB",
        "file_size_bytes": 352795
    },
    "http_response": {
        "final_url": "https://www.apple.com/",
        "status_code": 200,
        "content_type": "text/html",
        "page_content_empty": false,
        "ip": "69.192.160.210"
    },
    "html_info": {
        "title": "Apple",
        "description": "Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, and expert device support.",
        "og_image": "https://www.apple.com/ac/structured-data/images/open_graph_logo.png?202110180743",
        "icon": "",
        "og_site_name": "Apple",
        "ld_organization": "Apple",
        "canonical": "https://www.apple.com/",
        "robots": "",
        "twitter_site": "",
        "lang": "en-US"
    },
    "elapsed_ms": 5763
}
Code analysis

Key Features

Convert any URL or web page into high-quality printable PDF file

Businesses and startups use this URL to PDF API to convert web pages (such as a news, a review of a product, or a catalogue) into PDF file.

Web Page to PDF

This API can efficiently convert a web page into a PDF (with custom format) document file.

Change PDF Format

Customize the PDF: set paper size, format (A1, A4, etc), and also "fit" the web page into a one PDF page.

High-Quality Document

The API will create a high-quality and printable PDF document file of the submitted URL, you'll love it!

Fast Response

The PDF is generated in 10-20 seconds on average, depends on the complexity of the HTML code.

Common Use Cases

Take a look at some real-world use cases of this API service

Our API can be used in many ways, from cybersecurity tasks to marketing/research tasks. Here we showcase the most popular use cases according to our customers usage:

URL to PDF

Convert a invoice-like remote web pages into high-quality PDF for sending to your customers.

Save URL as PDF

Convert to PDF any web page, e.g a website homepage, product catalog or a blog/news article.

PDF for Presentations

Need to rended a specific URL to PDF? Simply use our API to generate the PDF file from a URL.

Automate Tasks

Use this API to effortlessly automate any manual task of converting URLs to PDF in no time.

Use cases

EVERYTHING YOU GET

Do it all with one PDF request

One request renders the live page in a real browser and returns the PDF ready to save, with full control over paper size, margins, page ranges and scale.

PDF page setup

  • A0 through A6 formats
  • Letter, Legal, Tabloid and Ledger
  • Custom paper width up to 5000px
  • Custom paper height up to 10000px
  • Margin control
  • Landscape orientation

Page selection and rendering

  • Select page ranges, e.g. 1 or 1-3
  • Fit the whole page on one sheet
  • Show or hide the page background
  • Emulate screen or print stylesheets
  • Custom viewport width and height
  • Wait up to 10s before rendering

Clean, uncluttered output

  • Advertisements disabled by default
  • Cookie consent banners disabled by default
  • Alerts and dialogs suppressed
  • Optionally disable images
  • Optionally disable JavaScript
  • No banner overlays in your archive

Headers and authentication

  • Basic Authentication
  • Authorization bearer token
  • Custom request header
  • Accept-Language override
  • Desktop or mobile user agent
  • Archive pages behind a login

Response and page metadata

  • Final URL after redirects
  • HTTP status code and content type
  • IP address that served the page
  • Title, description and canonical URL
  • Open Graph image and site name
  • Organisation from JSON-LD data

Built for developers

  • PDF returned as base64, ready to save
  • File size in bytes and human-readable form
  • UTC timestamp of the render
  • Real browser rendering, not an HTTP fetch
  • Up to 120s allowed for heavy pages
  • 20 credits per successful request

USAGE EXAMPLE

Learn how seamless it is to add and use Screenshot API anywhere you want

All it takes is a HTTPS POST request with JSON payload to our endpoint, and you’ll receive the response within seconds, usually within 10-20 seconds. Here are a few code examples to use the API:

$url = 'https://www.apivoid.com';

$apiUrl = 'https://api.apivoid.com/v2/url-to-pdf';
$apiKey = 'your_api_key_here';

$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json', 'X-API-Key: ' . $apiKey]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['url' => $url]));
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $responseData = json_decode($response, true);

    print_r($responseData);
} else {
    print_r('An error occurred: '.$response);
}

Start using our API services, it takes just a few minutes

Create your account, pick a subscription plan, and make your first API call instantly with your API key, simple as that!

Get started now