Legacy API (v1)

API Documentation

To make successful API requests, you need a verified account click here to sign up if you do not have an account already.

You can generate your API key in your PDF.to dashboard under the Developers section.

File to PDF

DOC to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.doc', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.doc', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.doc' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.doc' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.doc")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.doc")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

DOCX to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.docx', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.docx', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.docx' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.docx' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.docx")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.docx")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

XLS to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.xls', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.xls', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.xls' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.xls' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.xls")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.xls")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

XLSX to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.xlsx', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.xlsx', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.xlsx' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.xlsx' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.xlsx")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.xlsx")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

JPG to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.jpg', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.jpg', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.jpg' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.jpg' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.jpg")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.jpg")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

PNG to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.png', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.png', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.png' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.png' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.png")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.png")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

PPT to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.ppt', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.ppt', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.ppt' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.ppt' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.ppt")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.ppt")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

PPTX to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pptx', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pptx', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pptx' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pptx' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.pptx")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pptx")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

TXT to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.txt', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.txt', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.txt' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.txt' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.txt")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.txt")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

HTML to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.html', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.html', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.html' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.html' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.html")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.html")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

ODT to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.odt', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.odt', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.odt' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.odt' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.odt")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.odt")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

CSV to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.csv', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.csv', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.csv' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.csv' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.csv")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.csv")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

ePub to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.epub', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.epub', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.epub' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.epub' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.epub")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.epub")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

JPEG to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.jpeg', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.jpeg', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.jpeg' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.jpeg' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.jpeg")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.jpeg")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

ICO to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.ico', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.ico', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.ico' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.ico' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.ico")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.ico")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

BMP to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.bmp', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.bmp', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.bmp' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.bmp' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.bmp")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.bmp")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

SVG to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.svg', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.svg', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.svg' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.svg' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.svg")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.svg")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

TIFF to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.tiff', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.tiff', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.tiff' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.tiff' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.tiff")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.tiff")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

WebP to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.webp', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.webp', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.webp' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.webp' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.webp")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.webp")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

GIF to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.gif', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.gif', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.gif' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.gif' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.gif")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.gif")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

PSD to PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.psd', 'rb')}
params = {
    'convert_to': 'pdf'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pdf', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.psd', 'rb')}
params = {
    'convert_to': 'pdf',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pdf', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.psd' \
-F 'data={"convert_to": "pdf"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.psd' \
-F 'data={"convert_to": "pdf", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\"}",
        "file_contents" => curl_file_create("testing.psd")
    );
    $fp = fopen("file.pdf", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pdf\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.psd")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert files to .PDF you must be send the follow information:

Parameter Description
file
data
  • convert_to: pdf
  • To get a ZIP file you can pass zip: true

PDF to allowed file

PDF.to API allow users to convert any PDF file to:

.JPG, .PNG, .DOC, .PPT, .DOCX, .TXT, .HTML, .ODT, .CSV, .EPUB, .XLS, .XLSX, .PPTX, .TIFF, .JPEG

To .JPG

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'jpg'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.jpg', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'jpg',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'jpg'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'jpg', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "jpg"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.jpg
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "jpg", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"jpg\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.jpg", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"jpg\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .JPG you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: jpg
  • To get a ZIP file you can pass zip: true

To .PNG

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'png'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.png', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'png',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'png'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'png', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "png"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.png
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "png", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"png\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.png", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"png\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .PNG you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: png
  • To get a ZIP file you can pass zip: true

To .DOC

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'doc'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.doc', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'doc',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'doc'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'doc', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "doc"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.doc
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "doc", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"doc\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.doc", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"doc\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .DOC you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: doc
  • To get a ZIP file you can pass zip: true

To .PPT

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'ppt'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.ppt', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'ppt',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'ppt'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'ppt', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "ppt"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.ppt
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "ppt", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"ppt\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.ppt", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"ppt\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .PPT you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: ppt
  • To get a ZIP file you can pass zip: true

To .DOCX

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'docx'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.docx', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'docx',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'docx'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'docx', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "docx"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.docx
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "docx", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"docx\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.docx", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"docx\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .DOCX you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: docx
  • To get a ZIP file you can pass zip: true

To .TXT

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'txt'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.txt', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'txt',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'txt'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'txt', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "txt"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.txt
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "txt", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"txt\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.txt", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"txt\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .TXT you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: txt
  • To get a ZIP file you can pass zip: true

To .HTML

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'html'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.html', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'html',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'html'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'html', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "html"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.html
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "html", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"html\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.html", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"html\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .TXT you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: html
  • To get a ZIP file you can pass zip: true

To .ODT

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'odt'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.odt', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'odt',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'odt'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'odt', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "odt"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.odt
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "odt", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"odt\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.odt", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"odt\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .ODT you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: odt
  • To get a ZIP file you can pass zip: true

To .CSV

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'csv'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.csv', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'csv',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'csv'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'csv', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "csv"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.csv
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "csv", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"csv\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.csv", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"csv\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .CSV you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: csv
  • To get a ZIP file you can pass zip: true

To .EPUB

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'epub'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.epub', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'epub',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'epub'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'epub', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "epub"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.epub
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "epub", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"epub\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.epub", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"epub\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .EPUB you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: epub
  • To get a ZIP file you can pass zip: true

To .XLS

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'xls'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.xls', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'xls',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'xls'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'xls', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "xls"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.xls
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "xls", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"xls\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.xls", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"xls\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .XLS you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: xls
  • To get a ZIP file you can pass zip: true

To .XLSX

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'xlsx'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.xlsx', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'xlsx',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'xlsx'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'xlsx', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "xlsx"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.xlsx
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "xlsx", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"xlsx\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.xlsx", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"xlsx\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .XLSX you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: xlsx
  • To get a ZIP file you can pass zip: true

To .PPTX

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'pptx'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.pptx', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'pptx',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pptx'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'pptx', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "pptx"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pptx
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "pptx", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pptx\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.pptx", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"pptx\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .PPTX you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: pptx
  • To get a ZIP file you can pass zip: true

To .TIFF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'tiff'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.tiff', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'tiff',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'tiff'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'tiff', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "tiff"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.tiff
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "tiff", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"tiff\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.tiff", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"tiff\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .TIFF you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: tiff
  • To get a ZIP file you can pass zip: true

To .JPEG

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'jpeg'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.jpeg', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'jpeg',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'jpeg'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'jpeg', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "jpeg"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.jpeg
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "jpeg", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"jpeg\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.jpeg", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"jpeg\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .JPEG you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: jpeg
  • To get a ZIP file you can pass zip: true

To .ICO

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'ico'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.ico', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'ico',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'ico'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'ico', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "ico"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.ico
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "ico", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"ico\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.ico", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"ico\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .ICO you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: ico
  • To get a ZIP file you can pass zip: true

To .BMP

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'bmp'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.bmp', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'bmp',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'bmp'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'bmp', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "bmp"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.bmp
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "bmp", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"bmp\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.bmp", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"bmp\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .BMP you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: bmp
  • To get a ZIP file you can pass zip: true

To .SVG

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'svg'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.svg', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'svg',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'svg'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'svg', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "svg"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.svg
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "svg", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"svg\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.svg", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"svg\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .SVG you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: svg
  • To get a ZIP file you can pass zip: true

To .WEBP

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'webp'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.webp', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'webp',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'webp'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'webp', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "webp"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.webp
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "webp", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"webp\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.webp", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"webp\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .WEBP you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: webp
  • To get a ZIP file you can pass zip: true

To .GIF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'gif'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.gif', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'gif',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'gif'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'gif', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "gif"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.gif
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "gif", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"gif\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.gif", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"gif\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .GIF you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: gif
  • To get a ZIP file you can pass zip: true

To .PSD

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'psd'
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.psd', 'wb') as f:
    f.write(r.content)
# Convert file and get a ZIP
import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {
    'convert_to': 'psd',
    'zip': True
}
data = {'data': json.dumps(params)}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.zip', 'wb') as f:
    f.write(r.content)

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'psd'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.pdf'));
});
// Convert file and get a ZIP
const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'convert_to': 'psd', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "psd"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.psd
# Convert file and get a ZIP
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "psd", "zip": true}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.zip

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"psd\"}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.psd", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>
// Convert file and get a ZIP
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"psd\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

To convert PDF files to .PSD you must be send the follow information:

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data
  • convert_to: psd
  • To get a ZIP file you can pass zip: true

Tools

You can apply any of our valid tools to PDF files, you must send the desire tool in the body.

You can pass one of the following tools: organize, unlock or repair.

Organize PDF

POST https://pdf.to/v1/api

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"tool": "organize"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'tool': 'organize', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"tool\": \"organize\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {'tool': 'organize'}
data = {
    'data': json.dumps(params),
    'zip': False,
    'pages': {
        0: {
            'delete': True
        },
        2: {
            'rotate': 90,
            'order': 1
        }
    }
}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.docx', 'wb') as f:
    f.write(r.content)

This tool allow users to rotate, delete or change the page order of any PDF file uploaded.

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data

This parameter should contains the information of the tool to use and the pages to modify like:

  • tool: organize
  • pages: {0: {delete: True}, 2: {rotate: 90, order: 1}}}

The pages information will tell the API to modify one or more pages, you must indicate the page to modify by passing the page index (0 will be the page #1). In the example we are telling the API to delete the page #1, and rotate 90 degrees the page #3 and move it to page #2.

Unlock PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {'tool': 'unlock'}
data = {
    'data': json.dumps(params)
}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.docx', 'wb') as f:
    f.write(r.content)

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"tool": "unlock"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'tool': 'unlock', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"tool\": \"unlock\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

This tool allow users to remove any password protection of any PDF file uploaded.

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data

This parameter should contains the information of the tool to use and the pages to modify like:

  • tool: unlock

Repair PDF

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {'tool': 'repair'}
data = {
    'data': json.dumps(params)
}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.docx', 'wb') as f:
    f.write(r.content)

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"tool": "repair"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"tool\": \"repair\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'tool': 'repair', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

This tool allow users to fix any problem on any PDF file uploaded.

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data

This parameter should contains the information of the tool to use and the pages to modify like:

  • tool: repair

PDF to ZIP

POST https://pdf.to/v1/api

Python code example:

import requests
import json

url = 'https://pdf.to/v1/api'
files = {'file': open('testing.pdf', 'rb')}
params = {'tool': 'organize'}
data = {
    'data': json.dumps(params)
}
headers = {'Authorization': '<YOUR_API_KEY>'}

r = requests.post(
    url,
    files=files,
    data=data,
    headers=headers
)

with open('file.docx', 'wb') as f:
    f.write(r.content)

CURL code example:

curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"tool": "organize"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.pdf

NodeJS code example:

const request = require('request');
const fs = require('fs');

let req = request.post({
    url: 'https://pdf.to/v1/api',
    headers: {
        'Authorization': '<YOUR_API_KEY>'
    },
    formData: {
        file: fs.createReadStream('testing.pdf'),
        data: JSON.stringify({'tool': 'organize', 'zip': true})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('testing.zip'));
});

PHP code example:

<?php
    $post_data = array(
        "data" => "{\"tool\": \"organize\", \"zip\": true}",
        "file_contents" => curl_file_create("testing.pdf")
    );
    $fp = fopen("file.zip", "w+");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "https://pdf.to/v1/api");
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        "Authorization: <YOUR_API_KEY>"
    ));
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
    $content = curl_exec($curl);
    curl_close($curl);
    fclose($fp);
?>

You can zip your reponse files on any request by passing zip: true on the data information.

Parameter Description
file This tool can only be applied to PDF files, you must upload a PDF file in your request body.
data

This paramater should contains the information of the tool to use and the pages to modify like:

  • tool: organize
  • zip: true