NAV
python

Բարի գալուստ PDF.to API-ի փաստաթղթեր

Մշակողի բանալի ստանալու համար այցելեքմշակողների պորտալ

Authorization: <api_key>

Փոխարկել PDF- ից

PDF- ը DOCX- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-docx',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.docx

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը DOC- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-doc',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()
# Սեղմել PDF- ը

## Սեղմել PDF- ը

```python
import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-compress',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

get_results(convert_files(api_url, params, headers)) ```

Կվերադառնա

/path/to/local/file_processed.doc

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից JPG

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-jpg',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.jpg

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ի PNG- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-png',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.png

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից XLSX

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-xlsx',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.xlsx

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը XLS- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-xls',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.xls

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը PPTX- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-pptx',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pptx

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից PPT

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-ppt',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.ppt

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից TXT

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-txt',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.txt

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը HTML- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-html',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.html

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից ODT- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-odt',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.odt

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից CSV- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-csv',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.csv

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից ePub- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-epub',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.epub

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը TIFF- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-tiff',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.tiff

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը BMP- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-bmp',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.bmp

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ը SVG- ին

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-svg',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.svg

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից ZIP- ում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-zip',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.zip

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից WebP

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-webp',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.webp

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից GIF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-gif',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.gif

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PDF- ից PSD

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-psd',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.psd

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

Փոխարկել PDF- ին

DOCX to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.docx', 'testfiles/blah.docx', 'testfiles/blah.docx']
params = {
    'lang': 'en',
    'convert_to': 'docx-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

DOC to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'doc-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'xlsx-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

JPG- ից PDF- ում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'jpg-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PNG- ը PDF- ում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'png-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PPTX to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pptx-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PPT դեպի PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'ppt-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

TXT- ից PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.txt', 'testfiles/blah.txt', 'testfiles/blah.txt']
params = {
    'lang': 'en',
    'convert_to': 'txt-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

HTML to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.html', 'testfiles/blah.html', 'testfiles/blah.html']
params = {
    'lang': 'en',
    'convert_to': 'html-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

ODT- ը PDF- ում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.odt', 'testfiles/blah.odt', 'testfiles/blah.odt']
params = {
    'lang': 'en',
    'convert_to': 'odt-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

CSV- ին PDF- ում

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.csv', 'testfiles/blah.csv', 'testfiles/blah.csv']
params = {
    'lang': 'en',
    'convert_to': 'csv-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

ePub to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'epub-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

BMP to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.bmp', 'testfiles/blah.bmp', 'testfiles/blah.bmp']
params = {
    'lang': 'en',
    'convert_to': 'bmp-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

SVG to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.svg', 'testfiles/blah.svg', 'testfiles/blah.svg']
params = {
    'lang': 'en',
    'convert_to': 'svg-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

TIFF to PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.tiff', 'testfiles/blah.tiff', 'testfiles/blah.tiff']
params = {
    'lang': 'en',
    'convert_to': 'tiff-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

WebP- ից PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'webp-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

GIF- ը PDF- ով

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.gif', 'testfiles/blah.gif', 'testfiles/blah.gif']
params = {
    'lang': 'en',
    'convert_to': 'gif-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

PSD- ից PDF

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.psd', 'testfiles/blah.psd', 'testfiles/blah.psd']
params = {
    'lang': 'en',
    'convert_to': 'psd-pdf',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում

Սեղմել PDF- ը

Սեղմել PDF- ը

import requests
import time
import shutil
import json

headers = {'Authorization': 'yourapikeyfoundinadmin'}
file_list = ['testfiles/blah.pdf', 'testfiles/blah.pdf', 'testfiles/blah.pdf']
params = {
    'lang': 'en',
    'convert_to': 'pdf-compress',
    'ocr': False
}

api_url = 'https://api.pdf.to/v1/convert/'
results_url = 'https://api.pdf.to/v1/results/'


def download_file(url, local_filename):
    with requests.get("https://api.pdf.to/%s" % url, stream=True) as r:
        with open(local_filename, 'wb') as f:
            shutil.copyfileobj(r.raw, f)
    return local_filename


def convert_files(api_url, params, headers):
    files = [eval(f'("files", open("{file}", "rb"))') for file in file_list]
    print(files)
    r = requests.post(
        url=api_url,
        files=files,
        data=params,
        headers=headers
    )
    return r.json()


def get_results(params):
    if params.get('error'):
        return params.get('error')
    r = requests.post(
        url=results_url,
        data=params
    )
    data = r.json()
    finished = data.get('finished')
    while not finished:
        if int(data.get('queue_count')) > 0:
            print('queue: %s' % data.get('queue_count'))
        time.sleep(5)
        results = get_results(params)
        print(results)
        results = json.dumps(results)
        if results:
            break
    if finished:
        print(data.get('files'))
        for f in data.get('files'):
            print(f.get('url'))
            download_file("%s" % f.get('url'), "%s" % f.get('filename'))
        return {"finished": "files downloaded"}
    return r.json()


get_results(convert_files(api_url, params, headers))

Կվերադառնա

/path/to/local/file_processed.pdf

Բազմաթիվ դարձնելու համար պարզապես ավելի շատ ֆայլեր տեղադրեք ձեր ցուցակում