curl --request POST \
--url https://api.pdf.co/v1/pdf/convert/from/url \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://wikipedia.org/wiki/Wikipedia:Contact_us",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"printbackground": true,
"mediatype": "print",
"donotwaitfullload": false,
"header": "<string>",
"footer": "<string>",
"legacyrendition": true,
"name": "<string>",
"async": false,
"expiration": 60,
"profiles": "{ \"CustomScript\": \";; // put some custom js script here \"}",
"httpusername": "<string>",
"httppassword": "<string>"
}
'import requests
url = "https://api.pdf.co/v1/pdf/convert/from/url"
payload = {
"url": "https://wikipedia.org/wiki/Wikipedia:Contact_us",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"printbackground": True,
"mediatype": "print",
"donotwaitfullload": False,
"header": "<string>",
"footer": "<string>",
"legacyrendition": True,
"name": "<string>",
"async": False,
"expiration": 60,
"profiles": "{ \"CustomScript\": \";; // put some custom js script here \"}",
"httpusername": "<string>",
"httppassword": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://wikipedia.org/wiki/Wikipedia:Contact_us',
margins: '10px 10px 10px 10px',
papersize: 'A4',
orientation: 'Portrait',
printbackground: true,
mediatype: 'print',
donotwaitfullload: false,
header: '<string>',
footer: '<string>',
legacyrendition: true,
name: '<string>',
async: false,
expiration: 60,
profiles: '{ "CustomScript": ";; // put some custom js script here "}',
httpusername: '<string>',
httppassword: '<string>'
})
};
fetch('https://api.pdf.co/v1/pdf/convert/from/url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pdf.co/v1/pdf/convert/from/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://wikipedia.org/wiki/Wikipedia:Contact_us',
'margins' => '10px 10px 10px 10px',
'papersize' => 'A4',
'orientation' => 'Portrait',
'printbackground' => true,
'mediatype' => 'print',
'donotwaitfullload' => false,
'header' => '<string>',
'footer' => '<string>',
'legacyrendition' => true,
'name' => '<string>',
'async' => false,
'expiration' => 60,
'profiles' => '{ "CustomScript": ";; // put some custom js script here "}',
'httpusername' => '<string>',
'httppassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdf.co/v1/pdf/convert/from/url"
payload := strings.NewReader("{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdf.co/v1/pdf/convert/from/url")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdf.co/v1/pdf/convert/from/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Success",
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf",
"jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA",
"credits": 2,
"remainingCredits": 1480582,
"duration": 33
}{
"error": true,
"status": 400,
"message": "Bad request. Typically due to bad input parameters or unreachable input URLs (e.g., access restrictions like login or password)."
}{
"error": true,
"status": 401,
"message": "Unauthorized. Authentication is required and has failed or has not yet been provided."
}{
"error": true,
"status": 402,
"message": "Not enough credits."
}{
"error": true,
"status": 403,
"message": "Access forbidden for input URL."
}{
"error": true,
"status": 404,
"message": "The requested resource could not be found."
}{
"error": true,
"status": 408,
"message": "The server timed out waiting for the request."
}{
"error": true,
"status": 429,
"message": "Too many requests in a given time period."
}{
"error": true,
"status": 441,
"message": "Invalid Password. Password protected document."
}{
"error": true,
"status": 442,
"message": "Input document is damaged or of incorrect type."
}{
"error": true,
"status": 443,
"message": "Permissions. The operation is prohibited by document security settings."
}{
"error": true,
"status": 444,
"message": "Profiles parsing error. Please ensure that the configuration is supported."
}{
"error": true,
"status": 445,
"message": "Timeout error. For large documents, use asynchronous mode (async=true) and check status via /job/check."
}{
"error": true,
"status": 446,
"message": "Some files required for conversion are missing."
}{
"error": true,
"status": 447,
"message": "Invalid template."
}{
"error": true,
"status": 448,
"message": "Invalid URL or HTML. Ensure the provided URL is valid and accessible."
}{
"error": true,
"status": 449,
"message": "Invalid index range. Page index is out of range."
}{
"error": true,
"status": 450,
"message": "Invalid page range specified."
}{
"error": true,
"status": 452,
"message": "Invalid URL."
}{
"error": true,
"status": 454,
"message": "Invalid parameters."
}{
"error": true,
"status": 500,
"message": "Something went wrong. Please try again or contact support."
}PDF from URL (API Tester)
Run PDF from URL live from your browser — send a real request and see the response and credit usage, no code required. PDF.co API Tester.
curl --request POST \
--url https://api.pdf.co/v1/pdf/convert/from/url \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"url": "https://wikipedia.org/wiki/Wikipedia:Contact_us",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"printbackground": true,
"mediatype": "print",
"donotwaitfullload": false,
"header": "<string>",
"footer": "<string>",
"legacyrendition": true,
"name": "<string>",
"async": false,
"expiration": 60,
"profiles": "{ \"CustomScript\": \";; // put some custom js script here \"}",
"httpusername": "<string>",
"httppassword": "<string>"
}
'import requests
url = "https://api.pdf.co/v1/pdf/convert/from/url"
payload = {
"url": "https://wikipedia.org/wiki/Wikipedia:Contact_us",
"margins": "10px 10px 10px 10px",
"papersize": "A4",
"orientation": "Portrait",
"printbackground": True,
"mediatype": "print",
"donotwaitfullload": False,
"header": "<string>",
"footer": "<string>",
"legacyrendition": True,
"name": "<string>",
"async": False,
"expiration": 60,
"profiles": "{ \"CustomScript\": \";; // put some custom js script here \"}",
"httpusername": "<string>",
"httppassword": "<string>"
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
url: 'https://wikipedia.org/wiki/Wikipedia:Contact_us',
margins: '10px 10px 10px 10px',
papersize: 'A4',
orientation: 'Portrait',
printbackground: true,
mediatype: 'print',
donotwaitfullload: false,
header: '<string>',
footer: '<string>',
legacyrendition: true,
name: '<string>',
async: false,
expiration: 60,
profiles: '{ "CustomScript": ";; // put some custom js script here "}',
httpusername: '<string>',
httppassword: '<string>'
})
};
fetch('https://api.pdf.co/v1/pdf/convert/from/url', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pdf.co/v1/pdf/convert/from/url",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://wikipedia.org/wiki/Wikipedia:Contact_us',
'margins' => '10px 10px 10px 10px',
'papersize' => 'A4',
'orientation' => 'Portrait',
'printbackground' => true,
'mediatype' => 'print',
'donotwaitfullload' => false,
'header' => '<string>',
'footer' => '<string>',
'legacyrendition' => true,
'name' => '<string>',
'async' => false,
'expiration' => 60,
'profiles' => '{ "CustomScript": ";; // put some custom js script here "}',
'httpusername' => '<string>',
'httppassword' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pdf.co/v1/pdf/convert/from/url"
payload := strings.NewReader("{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pdf.co/v1/pdf/convert/from/url")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pdf.co/v1/pdf/convert/from/url")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"url\": \"https://wikipedia.org/wiki/Wikipedia:Contact_us\",\n \"margins\": \"10px 10px 10px 10px\",\n \"papersize\": \"A4\",\n \"orientation\": \"Portrait\",\n \"printbackground\": true,\n \"mediatype\": \"print\",\n \"donotwaitfullload\": false,\n \"header\": \"<string>\",\n \"footer\": \"<string>\",\n \"legacyrendition\": true,\n \"name\": \"<string>\",\n \"async\": false,\n \"expiration\": 60,\n \"profiles\": \"{ \\\"CustomScript\\\": \\\";; // put some custom js script here \\\"}\",\n \"httpusername\": \"<string>\",\n \"httppassword\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": "success",
"message": "Success",
"url": "https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf",
"jobId": "6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA",
"credits": 2,
"remainingCredits": 1480582,
"duration": 33
}{
"error": true,
"status": 400,
"message": "Bad request. Typically due to bad input parameters or unreachable input URLs (e.g., access restrictions like login or password)."
}{
"error": true,
"status": 401,
"message": "Unauthorized. Authentication is required and has failed or has not yet been provided."
}{
"error": true,
"status": 402,
"message": "Not enough credits."
}{
"error": true,
"status": 403,
"message": "Access forbidden for input URL."
}{
"error": true,
"status": 404,
"message": "The requested resource could not be found."
}{
"error": true,
"status": 408,
"message": "The server timed out waiting for the request."
}{
"error": true,
"status": 429,
"message": "Too many requests in a given time period."
}{
"error": true,
"status": 441,
"message": "Invalid Password. Password protected document."
}{
"error": true,
"status": 442,
"message": "Input document is damaged or of incorrect type."
}{
"error": true,
"status": 443,
"message": "Permissions. The operation is prohibited by document security settings."
}{
"error": true,
"status": 444,
"message": "Profiles parsing error. Please ensure that the configuration is supported."
}{
"error": true,
"status": 445,
"message": "Timeout error. For large documents, use asynchronous mode (async=true) and check status via /job/check."
}{
"error": true,
"status": 446,
"message": "Some files required for conversion are missing."
}{
"error": true,
"status": 447,
"message": "Invalid template."
}{
"error": true,
"status": 448,
"message": "Invalid URL or HTML. Ensure the provided URL is valid and accessible."
}{
"error": true,
"status": 449,
"message": "Invalid index range. Page index is out of range."
}{
"error": true,
"status": 450,
"message": "Invalid page range specified."
}{
"error": true,
"status": 452,
"message": "Invalid URL."
}{
"error": true,
"status": 454,
"message": "Invalid parameters."
}{
"error": true,
"status": 500,
"message": "Something went wrong. Please try again or contact support."
}Authorizations
Body
URL to the source file url attribute.
Set custom margins, overriding CSS default margins. Specify the margins in the format {top} {right} {bottom} {left}. You can usepx,mm,cmorinunits. Also, you can set margins for all sides at once using a single value.
"10px 10px 10px 10px"
Specifies the paper size. Accepts standard sizes like 'Letter', 'Legal', 'Tabloid', 'Ledger', 'A0'–'A6'. You can also set a custom size by providing width and height separated by a space, with optional units: px (pixels), mm (millimeters), cm (centimeters), or in (inches). Examples: '200 300', '200px 300px', '200mm 300mm', '20cm 30cm', '6in 8in'.
Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 "A4"
Sets the document orientation. Options: Portrait for vertical layout, and Landscape for horizontal layout.
Portrait, Landscape Set to false to disable background colors and images are included when generating PDFs from HTML/URL
Controls how content is rendered when converting to PDF. Options: print (uses print styles), screen (uses screen styles), none (no media type applied).
print, screen, none Controls how thoroughly the converter waits for a page to load before converting HTML to PDF --- false waits for full page load, while true speeds up conversion by waiting only for minimal loading.
Set this to can add user definable HTML for the header to be applied on every page header. The format is html.
Set this to can add user definable HTML for the footer to be applied on every page bottom. The format is html.
use legacy rendition (optional)
File name for generated output.
Set async to true for long processes to run in the background, API will then return a jobId which you can use with the Background Job Check endpoint. Also see Webhooks & Callbacks
Sets the expiration time for the output link, in minutes. After this period, generated output file(s) are automatically deleted from PDF.co Temporary Files Storage. The maximum allowed duration depends on your subscription plan. For permanent storage of input files (e.g., reusable images, PDF templates, documents), use PDF.co Built‑In Files Storage.
HTTP auth user name if required to access source URL.
HTTP auth password if required to access source URL.
Response
Success.
Status of the API response.
"success"
Descriptive message for the response status.
"Success"
URL to the output file.
"https://pdf-temp-files.s3.us-west-2.amazonaws.com/output.pdf"
Unique identifier for the job.
"6YSZD3U872ZYYFEDMQCQSGEEO8YSF5WA"
Credits used for this operation.
2
Credits remaining after this operation.
1480582
Time taken to complete the request, in milliseconds.
33
Was this page helpful?