API PDF pour les développeurs

Implémentez l'API de conversion PDF.to pour convertir n'importe quel PDF en DOC, DOCS, XLS, XLSX, PPT, PPTX, TXT, PNG, JPG, JPEG, TIFF, etc. ou pour convertir n'importe quel fichier en PDF.


* Nous ajoutons plus de fonctionnalités. Veuillez consulter notre documentation API pour plus d'informations


GET API KEY →
curl -POST 'https://pdf.to/v1/api' \
-F 'data=@/testing.pdf' \
-F 'data={"convert_to": "docx"}' \
-H 'Authorization: <YOUR_API_KEY>' \
--output file.docx
<?php
    $post_data = array(
        "data" => "{\"convert_to\": \"docx\"}",
        "file_contents" => curl_file_create("file.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);
?>
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)
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('file.pdf'),
        data: JSON.stringify({'convert_to': 'docx'})
    }
});

req.on('response', function(response) {
    response.pipe(fs.createWriteStream('file.docx'));
});