From 7a7ca6032ef413804c315bf603477720cb2ea997 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Wed, 25 Oct 2023 14:22:43 -0500 Subject: [PATCH 1/8] Add upload + raw JSON Python samples --- Python/JSON Payload/README.md | 10 ++++ Python/JSON Payload/bmp.py | 39 +++++++++++++ Python/JSON Payload/compressed-pdf.py | 39 +++++++++++++ Python/JSON Payload/decrypted-pdf.py | 39 +++++++++++++ Python/JSON Payload/encrypted-pdf.py | 38 +++++++++++++ Python/JSON Payload/exported-form-data.py | 39 +++++++++++++ Python/JSON Payload/extracted-text.py | 39 +++++++++++++ .../JSON Payload/flattened-annotations-pdf.py | 39 +++++++++++++ Python/JSON Payload/flattened-forms-pdf.py | 39 +++++++++++++ Python/JSON Payload/flattened-layers-pdf.py | 39 +++++++++++++ .../flattened-transparencies-pdf.py | 39 +++++++++++++ Python/JSON Payload/get-resource.py | 31 +++++++++++ Python/JSON Payload/gif.py | 39 +++++++++++++ Python/JSON Payload/html.py | 23 ++++++++ Python/JSON Payload/jpg.py | 39 +++++++++++++ Python/JSON Payload/linearized-pdf.py | 39 +++++++++++++ Python/JSON Payload/merged-pdf.py | 55 +++++++++++++++++++ Python/JSON Payload/pdf-info.py | 39 +++++++++++++ Python/JSON Payload/pdf-with-added-image.py | 55 +++++++++++++++++++ .../pdf-with-imported-form-data.py | 55 +++++++++++++++++++ Python/JSON Payload/pdf.py | 39 +++++++++++++ Python/JSON Payload/pdfa.py | 39 +++++++++++++ Python/JSON Payload/pdfx.py | 39 +++++++++++++ Python/JSON Payload/png.py | 39 +++++++++++++ Python/JSON Payload/restricted-pdf.py | 40 ++++++++++++++ Python/JSON Payload/split-pdf.py | 40 ++++++++++++++ Python/JSON Payload/tif.py | 39 +++++++++++++ Python/JSON Payload/unrestricted-pdf.py | 40 ++++++++++++++ Python/JSON Payload/upload.py | 19 +++++++ Python/JSON Payload/watermarked-pdf.py | 40 ++++++++++++++ Python/JSON Payload/zip.py | 55 +++++++++++++++++++ 31 files changed, 1203 insertions(+) create mode 100644 Python/JSON Payload/README.md create mode 100644 Python/JSON Payload/bmp.py create mode 100644 Python/JSON Payload/compressed-pdf.py create mode 100644 Python/JSON Payload/decrypted-pdf.py create mode 100644 Python/JSON Payload/encrypted-pdf.py create mode 100644 Python/JSON Payload/exported-form-data.py create mode 100644 Python/JSON Payload/extracted-text.py create mode 100644 Python/JSON Payload/flattened-annotations-pdf.py create mode 100644 Python/JSON Payload/flattened-forms-pdf.py create mode 100644 Python/JSON Payload/flattened-layers-pdf.py create mode 100644 Python/JSON Payload/flattened-transparencies-pdf.py create mode 100644 Python/JSON Payload/get-resource.py create mode 100644 Python/JSON Payload/gif.py create mode 100644 Python/JSON Payload/html.py create mode 100644 Python/JSON Payload/jpg.py create mode 100644 Python/JSON Payload/linearized-pdf.py create mode 100644 Python/JSON Payload/merged-pdf.py create mode 100644 Python/JSON Payload/pdf-info.py create mode 100644 Python/JSON Payload/pdf-with-added-image.py create mode 100644 Python/JSON Payload/pdf-with-imported-form-data.py create mode 100644 Python/JSON Payload/pdf.py create mode 100644 Python/JSON Payload/pdfa.py create mode 100644 Python/JSON Payload/pdfx.py create mode 100644 Python/JSON Payload/png.py create mode 100644 Python/JSON Payload/restricted-pdf.py create mode 100644 Python/JSON Payload/split-pdf.py create mode 100644 Python/JSON Payload/tif.py create mode 100644 Python/JSON Payload/unrestricted-pdf.py create mode 100644 Python/JSON Payload/upload.py create mode 100644 Python/JSON Payload/watermarked-pdf.py create mode 100644 Python/JSON Payload/zip.py diff --git a/Python/JSON Payload/README.md b/Python/JSON Payload/README.md new file mode 100644 index 0000000..914a5af --- /dev/null +++ b/Python/JSON Payload/README.md @@ -0,0 +1,10 @@ +This directory contains examples of how to call each endpoint of the +PdfRest API using Python. Please refer to https://pdfrest.com/documentation.html +for accepted inputs, options, and other specifics about individual endpoints. + +#### How to run Python samples + +Using Python3: + +1. `cd Python/` +2. `python name-of-sample-program.py` diff --git a/Python/JSON Payload/bmp.py b/Python/JSON Payload/bmp.py new file mode 100644 index 0000000..9d66ad7 --- /dev/null +++ b/Python/JSON Payload/bmp.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + bmp_data = { "id" : uploaded_id } + print(json.dumps(bmp_data, indent = 2)) + + + print("Processing file...") + bmp_response = requests.post(url='https://api.pdfrest.com/bmp', + data=json.dumps(bmp_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(bmp_response.status_code)) + if bmp_response.ok: + bmp_response_json = bmp_response.json() + print(json.dumps(bmp_response_json, indent = 2)) + + else: + print(bmp_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/compressed-pdf.py b/Python/JSON Payload/compressed-pdf.py new file mode 100644 index 0000000..829022b --- /dev/null +++ b/Python/JSON Payload/compressed-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + compress_data = { "id" : uploaded_id, "compression_level" : "low" } + print(json.dumps(compress_data, indent = 2)) + + + print("Processing file...") + compress_response = requests.post(url='https://api.pdfrest.com/compressed-pdf', + data=json.dumps(compress_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(compress_response.status_code)) + if compress_response.ok: + compress_response_json = compress_response.json() + print(json.dumps(compress_response_json, indent = 2)) + + else: + print(compress_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/decrypted-pdf.py b/Python/JSON Payload/decrypted-pdf.py new file mode 100644 index 0000000..71bc702 --- /dev/null +++ b/Python/JSON Payload/decrypted-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + decrypt_data = { "id" : uploaded_id, 'current_open_password': 'password' } + print(json.dumps(decrypt_data, indent = 2)) + + + print("Processing file...") + decrypt_response = requests.post(url='https://api.pdfrest.com/decrypted-pdf', + data=json.dumps(decrypt_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(decrypt_response.status_code)) + if decrypt_response.ok: + decrypt_response_json = decrypt_response.json() + print(json.dumps(decrypt_response_json, indent = 2)) + + else: + print(decrypt_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/encrypted-pdf.py b/Python/JSON Payload/encrypted-pdf.py new file mode 100644 index 0000000..d5c1685 --- /dev/null +++ b/Python/JSON Payload/encrypted-pdf.py @@ -0,0 +1,38 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + encrypt_data = { "id" : uploaded_id, 'new_open_password': 'password' } + print(json.dumps(encrypt_data, indent = 2)) + + print("Processing file...") + encrypt_response = requests.post(url='https://api.pdfrest.com/encrypted-pdf', + data=json.dumps(encrypt_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(encrypt_response.status_code)) + if encrypt_response.ok: + encrypt_response_json = encrypt_response.json() + print(json.dumps(encrypt_response_json, indent = 2)) + + else: + print(encrypt_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/exported-form-data.py b/Python/JSON Payload/exported-form-data.py new file mode 100644 index 0000000..3eba8e5 --- /dev/null +++ b/Python/JSON Payload/exported-form-data.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + export_data = { "id" : uploaded_id, 'data_format': 'xml' } + print(json.dumps(export_data, indent = 2)) + + + print("Processing file...") + export_response = requests.post(url='https://api.pdfrest.com/exported-form-data', + data=json.dumps(export_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(export_response.status_code)) + if export_response.ok: + export_response_json = export_response.json() + print(json.dumps(export_response_json, indent = 2)) + + else: + print(export_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/extracted-text.py b/Python/JSON Payload/extracted-text.py new file mode 100644 index 0000000..e88ea46 --- /dev/null +++ b/Python/JSON Payload/extracted-text.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + extract_data = { "id" : uploaded_id } + print(json.dumps(extract_data, indent = 2)) + + + print("Processing file...") + extract_response = requests.post(url='https://api.pdfrest.com/extracted-text', + data=json.dumps(extract_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(extract_response.status_code)) + if extract_response.ok: + extract_response_json = extract_response.json() + print(json.dumps(extract_response_json, indent = 2)) + + else: + print(extract_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/flattened-annotations-pdf.py b/Python/JSON Payload/flattened-annotations-pdf.py new file mode 100644 index 0000000..8953cb0 --- /dev/null +++ b/Python/JSON Payload/flattened-annotations-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + flatten_data = { "id" : uploaded_id } + print(json.dumps(flatten_data, indent = 2)) + + + print("Processing file...") + flatten_response = requests.post(url='https://api.pdfrest.com/flattened-annotations-pdf', + data=json.dumps(flatten_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(flatten_response.status_code)) + if flatten_response.ok: + flatten_response_json = flatten_response.json() + print(json.dumps(flatten_response_json, indent = 2)) + + else: + print(flatten_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/flattened-forms-pdf.py b/Python/JSON Payload/flattened-forms-pdf.py new file mode 100644 index 0000000..a14f285 --- /dev/null +++ b/Python/JSON Payload/flattened-forms-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + flatten_data = { "id" : uploaded_id } + print(json.dumps(flatten_data, indent = 2)) + + + print("Processing file...") + flatten_response = requests.post(url='https://api.pdfrest.com/flattened-forms-pdf', + data=json.dumps(flatten_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(flatten_response.status_code)) + if flatten_response.ok: + flatten_response_json = flatten_response.json() + print(json.dumps(flatten_response_json, indent = 2)) + + else: + print(flatten_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/flattened-layers-pdf.py b/Python/JSON Payload/flattened-layers-pdf.py new file mode 100644 index 0000000..a04f907 --- /dev/null +++ b/Python/JSON Payload/flattened-layers-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + flatten_data = { "id" : uploaded_id } + print(json.dumps(flatten_data, indent = 2)) + + + print("Processing file...") + flatten_response = requests.post(url='https://api.pdfrest.com/flattened-layers-pdf', + data=json.dumps(flatten_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(flatten_response.status_code)) + if flatten_response.ok: + flatten_response_json = flatten_response.json() + print(json.dumps(flatten_response_json, indent = 2)) + + else: + print(flatten_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/flattened-transparencies-pdf.py b/Python/JSON Payload/flattened-transparencies-pdf.py new file mode 100644 index 0000000..42b154c --- /dev/null +++ b/Python/JSON Payload/flattened-transparencies-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + flatten_data = { "id" : uploaded_id } + print(json.dumps(flatten_data, indent = 2)) + + + print("Processing file...") + flatten_response = requests.post(url='https://api.pdfrest.com/flattened-transparencies-pdf', + data=json.dumps(flatten_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(flatten_response.status_code)) + if flatten_response.ok: + flatten_response_json = flatten_response.json() + print(json.dumps(flatten_response_json, indent = 2)) + + else: + print(flatten_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/get-resource.py b/Python/JSON Payload/get-resource.py new file mode 100644 index 0000000..35ae3ab --- /dev/null +++ b/Python/JSON Payload/get-resource.py @@ -0,0 +1,31 @@ +import requests +import json + +# Resource UUIDs can be found in the JSON response of POST requests as "outputId". Resource UUIDs usually look like this: '0950b9bdf-0465-4d3f-8ea3-d2894f1ae839'. +id = 'xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' # place resource uuid here + +# The response format can be 'file' or 'url'. +# If 'url', then JSON containing the url of the resource file is returned. +# If 'file', then the file itself is returned. +format = 'file' + +resource_url = f"https://api.pdfrest.com/resource/{id}?format={format}" + +print("Sending GET request to /resource/{id} endpoint...") +response = requests.get(resource_url) + +print("Response status code: " + str(response.status_code)) + +if response.ok and format == 'url': + response_json = response.json() + print(json.dumps(response_json, indent = 2)) +elif response.ok and format == 'file': + # You will find a file (associated with the resource UUID above) in the same folder as the sample when the sample executes successfully. + output_file_name = response.headers.get("Content-Disposition").split("filename=")[1] + + with open(output_file_name, 'wb') as f: + f.write(response.content) + + print(f"The file {output_file_name} was created.") +else: + print(response.text) diff --git a/Python/JSON Payload/gif.py b/Python/JSON Payload/gif.py new file mode 100644 index 0000000..8466bfb --- /dev/null +++ b/Python/JSON Payload/gif.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + gif_data = { "id" : uploaded_id } + print(json.dumps(gif_data, indent = 2)) + + + print("Processing file...") + gif_response = requests.post(url='https://api.pdfrest.com/gif', + data=json.dumps(gif_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(gif_response.status_code)) + if gif_response.ok: + gif_response_json = gif_response.json() + print(json.dumps(gif_response_json, indent = 2)) + + else: + print(gif_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/html.py b/Python/JSON Payload/html.py new file mode 100644 index 0000000..9e4f142 --- /dev/null +++ b/Python/JSON Payload/html.py @@ -0,0 +1,23 @@ +import requests +import json + + +data = { + 'content': 'Web PageHello World!', + 'output': 'example_html_out' +} +print("Processing...") +response = requests.post(url='https://api.pdfrest.com/html', + data=json.dumps(data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("HTML response status code: " + str(response.status_code)) + +if response.ok: + response_json = response.json() + print(json.dumps(response_json, indent = 2)) + + + +else: + print(response.text) diff --git a/Python/JSON Payload/jpg.py b/Python/JSON Payload/jpg.py new file mode 100644 index 0000000..6878c23 --- /dev/null +++ b/Python/JSON Payload/jpg.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + jpg_data = { "id" : uploaded_id } + print(json.dumps(jpg_data, indent = 2)) + + + print("Processing file...") + jpg_response = requests.post(url='https://api.pdfrest.com/jpg', + data=json.dumps(jpg_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(jpg_response.status_code)) + if jpg_response.ok: + jpg_response_json = jpg_response.json() + print(json.dumps(jpg_response_json, indent = 2)) + + else: + print(jpg_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/linearized-pdf.py b/Python/JSON Payload/linearized-pdf.py new file mode 100644 index 0000000..017fedf --- /dev/null +++ b/Python/JSON Payload/linearized-pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + linearize_data = { "id" : uploaded_id } + print(json.dumps(linearize_data, indent = 2)) + + + print("Processing file...") + linearize_response = requests.post(url='https://api.pdfrest.com/linearized-pdf', + data=json.dumps(linearize_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(linearize_response.status_code)) + if linearize_response.ok: + linearize_response_json = linearize_response.json() + print(json.dumps(linearize_response_json, indent = 2)) + + else: + print(linearize_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/merged-pdf.py b/Python/JSON Payload/merged-pdf.py new file mode 100644 index 0000000..25ec6b1 --- /dev/null +++ b/Python/JSON Payload/merged-pdf.py @@ -0,0 +1,55 @@ +import requests +import json + +with open('/path/to/file1', 'rb') as f: + upload_data1 = f.read() + +print("Uploading file1...") +upload_response1 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data1, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response1.status_code)) + + +with open('/path/to/file2', 'rb') as f: + upload_data2 = f.read() + +print("Uploading file2...") +upload_response2 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data2, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response2.status_code)) + +if upload_response1.ok and upload_response2.ok: + upload_response_json1 = upload_response1.json() + print(json.dumps(upload_response_json1, indent = 2)) + + upload_response_json2 = upload_response2.json() + print(json.dumps(upload_response_json2, indent = 2)) + + + uploaded_id1 = upload_response_json1['files'][0]['id'] + uploaded_id2 = upload_response_json2['files'][0]['id'] + merge_data = { "id" : [uploaded_id1, uploaded_id2], "pages":[1,1], "type":["id", "id"] } + print(json.dumps(merge_data, indent = 2)) + + + print("Processing file...") + merge_response = requests.post(url='https://api.pdfrest.com/merged-pdf', + data=json.dumps(merge_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(merge_response.status_code)) + if merge_response.ok: + merge_response_json = merge_response.json() + print(json.dumps(merge_response_json, indent = 2)) + + else: + print(merge_response.text) +else: + print(upload_response1.text) + print(upload_response2.text) diff --git a/Python/JSON Payload/pdf-info.py b/Python/JSON Payload/pdf-info.py new file mode 100644 index 0000000..8758146 --- /dev/null +++ b/Python/JSON Payload/pdf-info.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + info_data = { "id" : uploaded_id, "queries": "title" } + print(json.dumps(info_data, indent = 2)) + + + print("Processing file...") + info_response = requests.post(url='https://api.pdfrest.com/pdf-info', + data=json.dumps(info_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(info_response.status_code)) + if info_response.ok: + info_response_json = info_response.json() + print(json.dumps(info_response_json, indent = 2)) + + else: + print(info_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/pdf-with-added-image.py b/Python/JSON Payload/pdf-with-added-image.py new file mode 100644 index 0000000..070faa7 --- /dev/null +++ b/Python/JSON Payload/pdf-with-added-image.py @@ -0,0 +1,55 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data1 = f.read() + +print("Uploading file1...") +upload_response1 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data1, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response1.status_code)) + + +with open('/path/to/file', 'rb') as f: + upload_data2 = f.read() + +print("Uploading file2...") +upload_response2 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data2, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response2.status_code)) + +if upload_response1.ok and upload_response2.ok: + upload_response_json1 = upload_response1.json() + print(json.dumps(upload_response_json1, indent = 2)) + + upload_response_json2 = upload_response2.json() + print(json.dumps(upload_response_json2, indent = 2)) + + + uploaded_id1 = upload_response_json1['files'][0]['id'] + uploaded_id2 = upload_response_json2['files'][0]['id'] + added_image_data = { "id" : uploaded_id1, "image_id": uploaded_id2, "x":0, "y":0, "page":1 } + print(json.dumps(added_image_data, indent = 2)) + + + print("Processing file...") + added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-added-image', + data=json.dumps(added_image_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(added_image_response.status_code)) + if added_image_response.ok: + added_image_response_json = added_image_response.json() + print(json.dumps(added_image_response_json, indent = 2)) + + else: + print(added_image_response.text) +else: + print(upload_response1.text) + print(upload_response2.text) diff --git a/Python/JSON Payload/pdf-with-imported-form-data.py b/Python/JSON Payload/pdf-with-imported-form-data.py new file mode 100644 index 0000000..2a49883 --- /dev/null +++ b/Python/JSON Payload/pdf-with-imported-form-data.py @@ -0,0 +1,55 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data1 = f.read() + +print("Uploading file1...") +upload_response1 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data1, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response1.status_code)) + + +with open('/path/to/file', 'rb') as f: + upload_data2 = f.read() + +print("Uploading file2...") +upload_response2 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data2, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'data.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response2.status_code)) + +if upload_response1.ok and upload_response2.ok: + upload_response_json1 = upload_response1.json() + print(json.dumps(upload_response_json1, indent = 2)) + + upload_response_json2 = upload_response2.json() + print(json.dumps(upload_response_json2, indent = 2)) + + + uploaded_id1 = upload_response_json1['files'][0]['id'] + uploaded_id2 = upload_response_json2['files'][0]['id'] + added_image_data = { "id" : uploaded_id1, "data_id": uploaded_id2, "x":0, "y":0, "page":1 } + print(json.dumps(added_image_data, indent = 2)) + + + print("Processing file...") + added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-added-image', + data=json.dumps(added_image_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(added_image_response.status_code)) + if added_image_response.ok: + added_image_response_json = added_image_response.json() + print(json.dumps(added_image_response_json, indent = 2)) + + else: + print(added_image_response.text) +else: + print(upload_response1.text) + print(upload_response2.text) diff --git a/Python/JSON Payload/pdf.py b/Python/JSON Payload/pdf.py new file mode 100644 index 0000000..10c6180 --- /dev/null +++ b/Python/JSON Payload/pdf.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + pdf_data = { "id" : uploaded_id } + print(json.dumps(pdf_data, indent = 2)) + + + print("Processing file...") + pdf_response = requests.post(url='https://api.pdfrest.com/pdf', + data=json.dumps(pdf_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(pdf_response.status_code)) + if pdf_response.ok: + pdf_response_json = pdf_response.json() + print(json.dumps(pdf_response_json, indent = 2)) + + else: + print(pdf_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/pdfa.py b/Python/JSON Payload/pdfa.py new file mode 100644 index 0000000..06a4e10 --- /dev/null +++ b/Python/JSON Payload/pdfa.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + pdfa_data = { "id" : uploaded_id, "output_type": "PDF/A-1b" } + print(json.dumps(pdfa_data, indent = 2)) + + + print("Processing file...") + pdfa_response = requests.post(url='https://api.pdfrest.com/pdfa', + data=json.dumps(pdfa_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(pdfa_response.status_code)) + if pdfa_response.ok: + pdfa_response_json = pdfa_response.json() + print(json.dumps(pdfa_response_json, indent = 2)) + + else: + print(pdfa_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/pdfx.py b/Python/JSON Payload/pdfx.py new file mode 100644 index 0000000..5c1d9d3 --- /dev/null +++ b/Python/JSON Payload/pdfx.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + pdfx_data = { "id" : uploaded_id, "output_type": "PDF/X-1a" } + print(json.dumps(pdfx_data, indent = 2)) + + + print("Processing file...") + pdfx_response = requests.post(url='https://api.pdfrest.com/pdfx', + data=json.dumps(pdfx_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(pdfx_response.status_code)) + if pdfx_response.ok: + pdfx_response_json = pdfx_response.json() + print(json.dumps(pdfx_response_json, indent = 2)) + + else: + print(pdfx_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/png.py b/Python/JSON Payload/png.py new file mode 100644 index 0000000..f5107e7 --- /dev/null +++ b/Python/JSON Payload/png.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + png_data = { "id" : uploaded_id } + print(json.dumps(png_data, indent = 2)) + + + print("Processing file...") + png_response = requests.post(url='https://api.pdfrest.com/png', + data=json.dumps(png_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(png_response.status_code)) + if png_response.ok: + png_response_json = png_response.json() + print(json.dumps(png_response_json, indent = 2)) + + else: + print(png_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/restricted-pdf.py b/Python/JSON Payload/restricted-pdf.py new file mode 100644 index 0000000..2649e8f --- /dev/null +++ b/Python/JSON Payload/restricted-pdf.py @@ -0,0 +1,40 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + restrict_data = { "id" : uploaded_id, "new_permissions_password": "password", "restrictions": ["print_low", "print_high", "edit_content"] } + + print(json.dumps(restrict_data, indent = 2)) + + + print("Processing file...") + restrict_response = requests.post(url='https://api.pdfrest.com/restricted-pdf', + data=json.dumps(restrict_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(restrict_response.status_code)) + if restrict_response.ok: + restrict_response_json = restrict_response.json() + print(json.dumps(restrict_response_json, indent = 2)) + + else: + print(restrict_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/split-pdf.py b/Python/JSON Payload/split-pdf.py new file mode 100644 index 0000000..3072404 --- /dev/null +++ b/Python/JSON Payload/split-pdf.py @@ -0,0 +1,40 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + split_data = { "id" : uploaded_id, "pages": ["1","2"]} + + print(json.dumps(split_data, indent = 2)) + + + print("Processing file...") + split_response = requests.post(url='https://api.pdfrest.com/split-pdf', + data=json.dumps(split_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(split_response.status_code)) + if split_response.ok: + split_response_json = split_response.json() + print(json.dumps(split_response_json, indent = 2)) + + else: + print(split_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/tif.py b/Python/JSON Payload/tif.py new file mode 100644 index 0000000..3f4e743 --- /dev/null +++ b/Python/JSON Payload/tif.py @@ -0,0 +1,39 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + tif_data = { "id" : uploaded_id } + print(json.dumps(tif_data, indent = 2)) + + + print("Processing file...") + tif_response = requests.post(url='https://api.pdfrest.com/tif', + data=json.dumps(tif_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(tif_response.status_code)) + if tif_response.ok: + tif_response_json = tif_response.json() + print(json.dumps(tif_response_json, indent = 2)) + + else: + print(tif_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/unrestricted-pdf.py b/Python/JSON Payload/unrestricted-pdf.py new file mode 100644 index 0000000..0fdf26a --- /dev/null +++ b/Python/JSON Payload/unrestricted-pdf.py @@ -0,0 +1,40 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + unrestrict_data = { "id" : uploaded_id, "current_permissions_password": "password" } + + print(json.dumps(unrestrict_data, indent = 2)) + + + print("Processing file...") + unrestrict_response = requests.post(url='https://api.pdfrest.com/unrestricted-pdf', + data=json.dumps(unrestrict_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(unrestrict_response.status_code)) + if unrestrict_response.ok: + unrestrict_response_json = unrestrict_response.json() + print(json.dumps(unrestrict_response_json, indent = 2)) + + else: + print(unrestrict_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/upload.py b/Python/JSON Payload/upload.py new file mode 100644 index 0000000..678ef80 --- /dev/null +++ b/Python/JSON Payload/upload.py @@ -0,0 +1,19 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + +else: + print(upload_response.text) diff --git a/Python/JSON Payload/watermarked-pdf.py b/Python/JSON Payload/watermarked-pdf.py new file mode 100644 index 0000000..d05819e --- /dev/null +++ b/Python/JSON Payload/watermarked-pdf.py @@ -0,0 +1,40 @@ +import requests +import json + +with open('/path/to/file', 'rb') as f: + upload_data = f.read() + +print("Uploading file...") +upload_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response.status_code)) + +if upload_response.ok: + upload_response_json = upload_response.json() + print(json.dumps(upload_response_json, indent = 2)) + + + uploaded_id = upload_response_json['files'][0]['id'] + watermark_data = { "id" : uploaded_id, "watermark_text": "I am watermarked" } + + print(json.dumps(watermark_data, indent = 2)) + + + print("Processing file...") + watermark_response = requests.post(url='https://api.pdfrest.com/watermarked-pdf', + data=json.dumps(watermark_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(watermark_response.status_code)) + if watermark_response.ok: + watermark_response_json = watermark_response.json() + print(json.dumps(watermark_response_json, indent = 2)) + + else: + print(watermark_response.text) +else: + print(upload_response.text) diff --git a/Python/JSON Payload/zip.py b/Python/JSON Payload/zip.py new file mode 100644 index 0000000..1840e12 --- /dev/null +++ b/Python/JSON Payload/zip.py @@ -0,0 +1,55 @@ +import requests +import json + +with open('/path/to/file1', 'rb') as f: + upload_data1 = f.read() + +print("Uploading file1...") +upload_response1 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data1, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response1.status_code)) + + +with open('/path/to/file2', 'rb') as f: + upload_data2 = f.read() + +print("Uploading file2...") +upload_response2 = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data2, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + +print("Upload response status code: " + str(upload_response2.status_code)) + +if upload_response1.ok and upload_response2.ok: + upload_response_json1 = upload_response1.json() + print(json.dumps(upload_response_json1, indent = 2)) + + upload_response_json2 = upload_response2.json() + print(json.dumps(upload_response_json2, indent = 2)) + + + uploaded_id1 = upload_response_json1['files'][0]['id'] + uploaded_id2 = upload_response_json2['files'][0]['id'] + zip_data = { "id" : [uploaded_id1, uploaded_id2] } + print(json.dumps(zip_data, indent = 2)) + + + print("Processing file...") + zip_response = requests.post(url='https://api.pdfrest.com/zip', + data=json.dumps(zip_data), + headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + + + + print("Processing response status code: " + str(zip_response.status_code)) + if zip_response.ok: + zip_response_json = zip_response.json() + print(json.dumps(zip_response_json, indent = 2)) + + else: + print(zip_response.text) +else: + print(upload_response1.text) + print(upload_response2.text) From 6b4d6b589c17ba6c96fe052e399e0481d6263501 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Thu, 26 Oct 2023 14:41:53 -0500 Subject: [PATCH 2/8] Added better file delineation to multi-file requests Rather than file1 and file2 we refer to them as data/image/first/second/pdf so that the code is hopefully more self documenting --- Python/JSON Payload/merged-pdf.py | 48 +++++++++---------- Python/JSON Payload/pdf-with-added-image.py | 48 +++++++++---------- .../pdf-with-imported-form-data.py | 48 +++++++++---------- Python/JSON Payload/zip.py | 48 +++++++++---------- 4 files changed, 96 insertions(+), 96 deletions(-) diff --git a/Python/JSON Payload/merged-pdf.py b/Python/JSON Payload/merged-pdf.py index 25ec6b1..07c9cc7 100644 --- a/Python/JSON Payload/merged-pdf.py +++ b/Python/JSON Payload/merged-pdf.py @@ -1,38 +1,38 @@ import requests import json -with open('/path/to/file1', 'rb') as f: - upload_data1 = f.read() +with open('/path/to/first_file', 'rb') as f: + upload_first_file_data = f.read() -print("Uploading file1...") -upload_response1 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data1, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading first PDF file...") +upload_first_file_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_first_file_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response1.status_code)) +print("First upload response status code: " + str(upload_first_file_response.status_code)) -with open('/path/to/file2', 'rb') as f: - upload_data2 = f.read() +with open('/path/to/second_file', 'rb') as f: + upload_second_file_data = f.read() -print("Uploading file2...") -upload_response2 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data2, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading second PDF file...") +upload_second_file_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_second_file_data , + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'second_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response2.status_code)) +print("Second upload response status code: " + str(upload_second_file_response.status_code)) -if upload_response1.ok and upload_response2.ok: - upload_response_json1 = upload_response1.json() - print(json.dumps(upload_response_json1, indent = 2)) +if upload_first_file_response.ok and upload_second_file_response.ok: + upload_first_file_response_json = upload_first_file_response.json() + print(json.dumps(upload_first_file_response_json, indent = 2)) - upload_response_json2 = upload_response2.json() - print(json.dumps(upload_response_json2, indent = 2)) + upload_second_file_response_json = upload_second_file_response.json() + print(json.dumps(upload_second_file_response_json, indent = 2)) - uploaded_id1 = upload_response_json1['files'][0]['id'] - uploaded_id2 = upload_response_json2['files'][0]['id'] - merge_data = { "id" : [uploaded_id1, uploaded_id2], "pages":[1,1], "type":["id", "id"] } + uploaded_first_file_id = upload_first_file_response_json['files'][0]['id'] + uploaded_second_file_id = upload_second_file_response_json['files'][0]['id'] + merge_data = { "id" : [uploaded_first_file_id, uploaded_second_file_id], "pages":[1,1], "type":["id", "id"] } print(json.dumps(merge_data, indent = 2)) @@ -51,5 +51,5 @@ else: print(merge_response.text) else: - print(upload_response1.text) - print(upload_response2.text) + print(upload_first_file_response.text) + print(upload_second_file_response.text) diff --git a/Python/JSON Payload/pdf-with-added-image.py b/Python/JSON Payload/pdf-with-added-image.py index 070faa7..6ea1ef9 100644 --- a/Python/JSON Payload/pdf-with-added-image.py +++ b/Python/JSON Payload/pdf-with-added-image.py @@ -1,38 +1,38 @@ import requests import json -with open('/path/to/file', 'rb') as f: - upload_data1 = f.read() +with open('/path/to/pdf_file', 'rb') as f: + upload_pdf_data = f.read() -print("Uploading file1...") -upload_response1 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data1, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading PDF file...") +upload_pdf_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_pdf_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'pdf_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response1.status_code)) +print("Upload PDF response status code: " + str(upload_pdf_response.status_code)) -with open('/path/to/file', 'rb') as f: - upload_data2 = f.read() +with open('/path/to/image_file', 'rb') as f: + upload_image_data = f.read() -print("Uploading file2...") -upload_response2 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data2, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading image file...") +upload_image_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_image_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'image_file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response2.status_code)) +print("Upload image response status code: " + str(upload_image_response.status_code)) -if upload_response1.ok and upload_response2.ok: - upload_response_json1 = upload_response1.json() - print(json.dumps(upload_response_json1, indent = 2)) +if upload_pdf_response.ok and upload_image_response.ok: + upload_pdf_response_json = upload_pdf_response.json() + print(json.dumps(upload_pdf_response_json, indent = 2)) - upload_response_json2 = upload_response2.json() - print(json.dumps(upload_response_json2, indent = 2)) + upload_image_response_json = upload_image_response.json() + print(json.dumps(upload_image_response_json, indent = 2)) - uploaded_id1 = upload_response_json1['files'][0]['id'] - uploaded_id2 = upload_response_json2['files'][0]['id'] - added_image_data = { "id" : uploaded_id1, "image_id": uploaded_id2, "x":0, "y":0, "page":1 } + uploaded_pdf_id = upload_pdf_response_json['files'][0]['id'] + uploaded_file_id = upload_image_response_json['files'][0]['id'] + added_image_data = { "id" : uploaded_pdf_id, "image_id": uploaded_file_id, "x":0, "y":0, "page":1 } print(json.dumps(added_image_data, indent = 2)) @@ -51,5 +51,5 @@ else: print(added_image_response.text) else: - print(upload_response1.text) - print(upload_response2.text) + print(upload_pdf_response.text) + print(upload_image_response.text) diff --git a/Python/JSON Payload/pdf-with-imported-form-data.py b/Python/JSON Payload/pdf-with-imported-form-data.py index 2a49883..bf815a7 100644 --- a/Python/JSON Payload/pdf-with-imported-form-data.py +++ b/Python/JSON Payload/pdf-with-imported-form-data.py @@ -1,38 +1,38 @@ import requests import json -with open('/path/to/file', 'rb') as f: - upload_data1 = f.read() +with open('/path/to/pdf_file', 'rb') as f: + upload_pdf_data = f.read() -print("Uploading file1...") -upload_response1 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data1, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading PDF file...") +upload_pdf_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_pdf_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'pdf_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response1.status_code)) +print("Upload PDF response status code: " + str(upload_pdf_response.status_code)) -with open('/path/to/file', 'rb') as f: - upload_data2 = f.read() +with open('/path/to/data_file', 'rb') as f: + upload_data_data = f.read() -print("Uploading file2...") -upload_response2 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data2, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'data.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading data file...") +upload_data_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_data_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'data_file.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response2.status_code)) +print("Upload data file response status code: " + str(upload_data_response.status_code)) -if upload_response1.ok and upload_response2.ok: - upload_response_json1 = upload_response1.json() - print(json.dumps(upload_response_json1, indent = 2)) +if upload_pdf_response.ok and upload_data_response.ok: + upload_pdf_response_json = upload_pdf_response.json() + print(json.dumps(upload_pdf_response_json, indent = 2)) - upload_response_json2 = upload_response2.json() - print(json.dumps(upload_response_json2, indent = 2)) + upload_data_response_json = upload_data_response.json() + print(json.dumps(upload_data_response_json, indent = 2)) - uploaded_id1 = upload_response_json1['files'][0]['id'] - uploaded_id2 = upload_response_json2['files'][0]['id'] - added_image_data = { "id" : uploaded_id1, "data_id": uploaded_id2, "x":0, "y":0, "page":1 } + uploaded_pdf_id = upload_pdf_response_json['files'][0]['id'] + uploaded_data_id = upload_data_response_json['files'][0]['id'] + added_image_data = { "id" : uploaded_pdf_id, "data_id": uploaded_data_id } print(json.dumps(added_image_data, indent = 2)) @@ -51,5 +51,5 @@ else: print(added_image_response.text) else: - print(upload_response1.text) - print(upload_response2.text) + print(upload_pdf_response.text) + print(upload_data_response.text) diff --git a/Python/JSON Payload/zip.py b/Python/JSON Payload/zip.py index 1840e12..0b72144 100644 --- a/Python/JSON Payload/zip.py +++ b/Python/JSON Payload/zip.py @@ -1,38 +1,38 @@ import requests import json -with open('/path/to/file1', 'rb') as f: - upload_data1 = f.read() +with open('/path/to/first_file', 'rb') as f: + upload_first_file_data = f.read() -print("Uploading file1...") -upload_response1 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data1, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file1.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading first file...") +upload_first_file_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_first_file_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response1.status_code)) +print("First upload response status code: " + str(upload_first_file_response.status_code)) -with open('/path/to/file2', 'rb') as f: - upload_data2 = f.read() +with open('/path/to/second_file', 'rb') as f: + upload_second_file_data = f.read() -print("Uploading file2...") -upload_response2 = requests.post(url='https://api.pdfrest.com/upload', - data=upload_data2, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file2.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) +print("Uploading second file...") +upload_second_file_response = requests.post(url='https://api.pdfrest.com/upload', + data=upload_second_file_data, + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'second_file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) -print("Upload response status code: " + str(upload_response2.status_code)) +print("Second upload response status code: " + str(upload_second_file_response.status_code)) -if upload_response1.ok and upload_response2.ok: - upload_response_json1 = upload_response1.json() - print(json.dumps(upload_response_json1, indent = 2)) +if upload_first_file_response.ok and upload_second_file_response.ok: + upload_first_file_response_json = upload_first_file_response.json() + print(json.dumps(upload_first_file_response_json, indent = 2)) - upload_response_json2 = upload_response2.json() - print(json.dumps(upload_response_json2, indent = 2)) + upload_second_file_response_json = upload_second_file_response.json() + print(json.dumps(upload_second_file_response_json, indent = 2)) - uploaded_id1 = upload_response_json1['files'][0]['id'] - uploaded_id2 = upload_response_json2['files'][0]['id'] - zip_data = { "id" : [uploaded_id1, uploaded_id2] } + uploaded_first_file_id = upload_first_file_response_json['files'][0]['id'] + uploaded_second_file_id = upload_second_file_response_json['files'][0]['id'] + zip_data = { "id" : [uploaded_first_file_id, uploaded_second_file_id] } print(json.dumps(zip_data, indent = 2)) @@ -51,5 +51,5 @@ else: print(zip_response.text) else: - print(upload_response1.text) - print(upload_response2.text) + print(upload_first_file_response.text) + print(upload_second_file_response.text) From 1b3c85359b012caa2da0d86c892db5ce2293eea3 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Thu, 26 Oct 2023 15:43:10 -0500 Subject: [PATCH 3/8] Change 'content-filename' to 'Content-Filename' --- Python/JSON Payload/bmp.py | 2 +- Python/JSON Payload/compressed-pdf.py | 2 +- Python/JSON Payload/decrypted-pdf.py | 2 +- Python/JSON Payload/encrypted-pdf.py | 2 +- Python/JSON Payload/exported-form-data.py | 2 +- Python/JSON Payload/extracted-text.py | 2 +- Python/JSON Payload/flattened-annotations-pdf.py | 2 +- Python/JSON Payload/flattened-forms-pdf.py | 2 +- Python/JSON Payload/flattened-layers-pdf.py | 2 +- Python/JSON Payload/flattened-transparencies-pdf.py | 2 +- Python/JSON Payload/gif.py | 2 +- Python/JSON Payload/jpg.py | 2 +- Python/JSON Payload/linearized-pdf.py | 2 +- Python/JSON Payload/merged-pdf.py | 2 +- Python/JSON Payload/pdf-info.py | 2 +- Python/JSON Payload/pdf-with-added-image.py | 2 +- Python/JSON Payload/pdf-with-imported-form-data.py | 2 +- Python/JSON Payload/pdf.py | 2 +- Python/JSON Payload/pdfa.py | 2 +- Python/JSON Payload/pdfx.py | 2 +- Python/JSON Payload/png.py | 2 +- Python/JSON Payload/restricted-pdf.py | 2 +- Python/JSON Payload/split-pdf.py | 2 +- Python/JSON Payload/tif.py | 2 +- Python/JSON Payload/unrestricted-pdf.py | 2 +- Python/JSON Payload/upload.py | 2 +- Python/JSON Payload/watermarked-pdf.py | 2 +- Python/JSON Payload/zip.py | 2 +- 28 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Python/JSON Payload/bmp.py b/Python/JSON Payload/bmp.py index 9d66ad7..38fc76b 100644 --- a/Python/JSON Payload/bmp.py +++ b/Python/JSON Payload/bmp.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/compressed-pdf.py b/Python/JSON Payload/compressed-pdf.py index 829022b..435ae47 100644 --- a/Python/JSON Payload/compressed-pdf.py +++ b/Python/JSON Payload/compressed-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/decrypted-pdf.py b/Python/JSON Payload/decrypted-pdf.py index 71bc702..fbe2fed 100644 --- a/Python/JSON Payload/decrypted-pdf.py +++ b/Python/JSON Payload/decrypted-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/encrypted-pdf.py b/Python/JSON Payload/encrypted-pdf.py index d5c1685..7e8f7b4 100644 --- a/Python/JSON Payload/encrypted-pdf.py +++ b/Python/JSON Payload/encrypted-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/exported-form-data.py b/Python/JSON Payload/exported-form-data.py index 3eba8e5..d534d53 100644 --- a/Python/JSON Payload/exported-form-data.py +++ b/Python/JSON Payload/exported-form-data.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/extracted-text.py b/Python/JSON Payload/extracted-text.py index e88ea46..56f4096 100644 --- a/Python/JSON Payload/extracted-text.py +++ b/Python/JSON Payload/extracted-text.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/flattened-annotations-pdf.py b/Python/JSON Payload/flattened-annotations-pdf.py index 8953cb0..e9890c8 100644 --- a/Python/JSON Payload/flattened-annotations-pdf.py +++ b/Python/JSON Payload/flattened-annotations-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/flattened-forms-pdf.py b/Python/JSON Payload/flattened-forms-pdf.py index a14f285..0e8df48 100644 --- a/Python/JSON Payload/flattened-forms-pdf.py +++ b/Python/JSON Payload/flattened-forms-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/flattened-layers-pdf.py b/Python/JSON Payload/flattened-layers-pdf.py index a04f907..1eed1b1 100644 --- a/Python/JSON Payload/flattened-layers-pdf.py +++ b/Python/JSON Payload/flattened-layers-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/flattened-transparencies-pdf.py b/Python/JSON Payload/flattened-transparencies-pdf.py index 42b154c..8d73b71 100644 --- a/Python/JSON Payload/flattened-transparencies-pdf.py +++ b/Python/JSON Payload/flattened-transparencies-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/gif.py b/Python/JSON Payload/gif.py index 8466bfb..dbd0eb2 100644 --- a/Python/JSON Payload/gif.py +++ b/Python/JSON Payload/gif.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/jpg.py b/Python/JSON Payload/jpg.py index 6878c23..8c58ad1 100644 --- a/Python/JSON Payload/jpg.py +++ b/Python/JSON Payload/jpg.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/linearized-pdf.py b/Python/JSON Payload/linearized-pdf.py index 017fedf..97cb223 100644 --- a/Python/JSON Payload/linearized-pdf.py +++ b/Python/JSON Payload/linearized-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/merged-pdf.py b/Python/JSON Payload/merged-pdf.py index 07c9cc7..20c0819 100644 --- a/Python/JSON Payload/merged-pdf.py +++ b/Python/JSON Payload/merged-pdf.py @@ -7,7 +7,7 @@ print("Uploading first PDF file...") upload_first_file_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_first_file_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("First upload response status code: " + str(upload_first_file_response.status_code)) diff --git a/Python/JSON Payload/pdf-info.py b/Python/JSON Payload/pdf-info.py index 8758146..74d92b8 100644 --- a/Python/JSON Payload/pdf-info.py +++ b/Python/JSON Payload/pdf-info.py @@ -18,7 +18,7 @@ uploaded_id = upload_response_json['files'][0]['id'] info_data = { "id" : uploaded_id, "queries": "title" } - print(json.dumps(info_data, indent = 2)) + print(json.dumps(info_data, indent = 2))Content-Filename print("Processing file...") diff --git a/Python/JSON Payload/pdf-with-added-image.py b/Python/JSON Payload/pdf-with-added-image.py index 6ea1ef9..89419b9 100644 --- a/Python/JSON Payload/pdf-with-added-image.py +++ b/Python/JSON Payload/pdf-with-added-image.py @@ -7,7 +7,7 @@ print("Uploading PDF file...") upload_pdf_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_pdf_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'pdf_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'pdf_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload PDF response status code: " + str(upload_pdf_response.status_code)) diff --git a/Python/JSON Payload/pdf-with-imported-form-data.py b/Python/JSON Payload/pdf-with-imported-form-data.py index bf815a7..8fcd012 100644 --- a/Python/JSON Payload/pdf-with-imported-form-data.py +++ b/Python/JSON Payload/pdf-with-imported-form-data.py @@ -18,7 +18,7 @@ print("Uploading data file...") upload_data_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'data_file.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'data_file.xml', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload data file response status code: " + str(upload_data_response.status_code)) diff --git a/Python/JSON Payload/pdf.py b/Python/JSON Payload/pdf.py index 10c6180..90b7b9a 100644 --- a/Python/JSON Payload/pdf.py +++ b/Python/JSON Payload/pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/pdfa.py b/Python/JSON Payload/pdfa.py index 06a4e10..238ae05 100644 --- a/Python/JSON Payload/pdfa.py +++ b/Python/JSON Payload/pdfa.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/pdfx.py b/Python/JSON Payload/pdfx.py index 5c1d9d3..f6b8457 100644 --- a/Python/JSON Payload/pdfx.py +++ b/Python/JSON Payload/pdfx.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/png.py b/Python/JSON Payload/png.py index f5107e7..ba73bd7 100644 --- a/Python/JSON Payload/png.py +++ b/Python/JSON Payload/png.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/restricted-pdf.py b/Python/JSON Payload/restricted-pdf.py index 2649e8f..9a1dfa1 100644 --- a/Python/JSON Payload/restricted-pdf.py +++ b/Python/JSON Payload/restricted-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/split-pdf.py b/Python/JSON Payload/split-pdf.py index 3072404..f124009 100644 --- a/Python/JSON Payload/split-pdf.py +++ b/Python/JSON Payload/split-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/tif.py b/Python/JSON Payload/tif.py index 3f4e743..8d49dc5 100644 --- a/Python/JSON Payload/tif.py +++ b/Python/JSON Payload/tif.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/unrestricted-pdf.py b/Python/JSON Payload/unrestricted-pdf.py index 0fdf26a..4f753d7 100644 --- a/Python/JSON Payload/unrestricted-pdf.py +++ b/Python/JSON Payload/unrestricted-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/upload.py b/Python/JSON Payload/upload.py index 678ef80..fc1a72f 100644 --- a/Python/JSON Payload/upload.py +++ b/Python/JSON Payload/upload.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/watermarked-pdf.py b/Python/JSON Payload/watermarked-pdf.py index d05819e..181f03c 100644 --- a/Python/JSON Payload/watermarked-pdf.py +++ b/Python/JSON Payload/watermarked-pdf.py @@ -7,7 +7,7 @@ print("Uploading file...") upload_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Upload response status code: " + str(upload_response.status_code)) diff --git a/Python/JSON Payload/zip.py b/Python/JSON Payload/zip.py index 0b72144..2c83250 100644 --- a/Python/JSON Payload/zip.py +++ b/Python/JSON Payload/zip.py @@ -7,7 +7,7 @@ print("Uploading first file...") upload_first_file_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_first_file_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("First upload response status code: " + str(upload_first_file_response.status_code)) From 97b34695439f6180d59c207eb608c7f45657781b Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Fri, 27 Oct 2023 09:32:02 -0500 Subject: [PATCH 4/8] Move new samples under "Endpoint Examples" --- Python/{ => Endpoint Examples}/JSON Payload/README.md | 0 Python/{ => Endpoint Examples}/JSON Payload/bmp.py | 0 Python/{ => Endpoint Examples}/JSON Payload/compressed-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/decrypted-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/encrypted-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/exported-form-data.py | 0 Python/{ => Endpoint Examples}/JSON Payload/extracted-text.py | 0 .../JSON Payload/flattened-annotations-pdf.py | 0 .../{ => Endpoint Examples}/JSON Payload/flattened-forms-pdf.py | 0 .../{ => Endpoint Examples}/JSON Payload/flattened-layers-pdf.py | 0 .../JSON Payload/flattened-transparencies-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/get-resource.py | 0 Python/{ => Endpoint Examples}/JSON Payload/gif.py | 0 Python/{ => Endpoint Examples}/JSON Payload/html.py | 0 Python/{ => Endpoint Examples}/JSON Payload/jpg.py | 0 Python/{ => Endpoint Examples}/JSON Payload/linearized-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/merged-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/pdf-info.py | 0 .../{ => Endpoint Examples}/JSON Payload/pdf-with-added-image.py | 0 .../JSON Payload/pdf-with-imported-form-data.py | 0 Python/{ => Endpoint Examples}/JSON Payload/pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/pdfa.py | 0 Python/{ => Endpoint Examples}/JSON Payload/pdfx.py | 0 Python/{ => Endpoint Examples}/JSON Payload/png.py | 0 Python/{ => Endpoint Examples}/JSON Payload/restricted-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/split-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/tif.py | 0 Python/{ => Endpoint Examples}/JSON Payload/unrestricted-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/upload.py | 0 Python/{ => Endpoint Examples}/JSON Payload/watermarked-pdf.py | 0 Python/{ => Endpoint Examples}/JSON Payload/zip.py | 0 31 files changed, 0 insertions(+), 0 deletions(-) rename Python/{ => Endpoint Examples}/JSON Payload/README.md (100%) rename Python/{ => Endpoint Examples}/JSON Payload/bmp.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/compressed-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/decrypted-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/encrypted-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/exported-form-data.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/extracted-text.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/flattened-annotations-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/flattened-forms-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/flattened-layers-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/flattened-transparencies-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/get-resource.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/gif.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/html.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/jpg.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/linearized-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/merged-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdf-info.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdf-with-added-image.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdf-with-imported-form-data.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdfa.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/pdfx.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/png.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/restricted-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/split-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/tif.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/unrestricted-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/upload.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/watermarked-pdf.py (100%) rename Python/{ => Endpoint Examples}/JSON Payload/zip.py (100%) diff --git a/Python/JSON Payload/README.md b/Python/Endpoint Examples/JSON Payload/README.md similarity index 100% rename from Python/JSON Payload/README.md rename to Python/Endpoint Examples/JSON Payload/README.md diff --git a/Python/JSON Payload/bmp.py b/Python/Endpoint Examples/JSON Payload/bmp.py similarity index 100% rename from Python/JSON Payload/bmp.py rename to Python/Endpoint Examples/JSON Payload/bmp.py diff --git a/Python/JSON Payload/compressed-pdf.py b/Python/Endpoint Examples/JSON Payload/compressed-pdf.py similarity index 100% rename from Python/JSON Payload/compressed-pdf.py rename to Python/Endpoint Examples/JSON Payload/compressed-pdf.py diff --git a/Python/JSON Payload/decrypted-pdf.py b/Python/Endpoint Examples/JSON Payload/decrypted-pdf.py similarity index 100% rename from Python/JSON Payload/decrypted-pdf.py rename to Python/Endpoint Examples/JSON Payload/decrypted-pdf.py diff --git a/Python/JSON Payload/encrypted-pdf.py b/Python/Endpoint Examples/JSON Payload/encrypted-pdf.py similarity index 100% rename from Python/JSON Payload/encrypted-pdf.py rename to Python/Endpoint Examples/JSON Payload/encrypted-pdf.py diff --git a/Python/JSON Payload/exported-form-data.py b/Python/Endpoint Examples/JSON Payload/exported-form-data.py similarity index 100% rename from Python/JSON Payload/exported-form-data.py rename to Python/Endpoint Examples/JSON Payload/exported-form-data.py diff --git a/Python/JSON Payload/extracted-text.py b/Python/Endpoint Examples/JSON Payload/extracted-text.py similarity index 100% rename from Python/JSON Payload/extracted-text.py rename to Python/Endpoint Examples/JSON Payload/extracted-text.py diff --git a/Python/JSON Payload/flattened-annotations-pdf.py b/Python/Endpoint Examples/JSON Payload/flattened-annotations-pdf.py similarity index 100% rename from Python/JSON Payload/flattened-annotations-pdf.py rename to Python/Endpoint Examples/JSON Payload/flattened-annotations-pdf.py diff --git a/Python/JSON Payload/flattened-forms-pdf.py b/Python/Endpoint Examples/JSON Payload/flattened-forms-pdf.py similarity index 100% rename from Python/JSON Payload/flattened-forms-pdf.py rename to Python/Endpoint Examples/JSON Payload/flattened-forms-pdf.py diff --git a/Python/JSON Payload/flattened-layers-pdf.py b/Python/Endpoint Examples/JSON Payload/flattened-layers-pdf.py similarity index 100% rename from Python/JSON Payload/flattened-layers-pdf.py rename to Python/Endpoint Examples/JSON Payload/flattened-layers-pdf.py diff --git a/Python/JSON Payload/flattened-transparencies-pdf.py b/Python/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.py similarity index 100% rename from Python/JSON Payload/flattened-transparencies-pdf.py rename to Python/Endpoint Examples/JSON Payload/flattened-transparencies-pdf.py diff --git a/Python/JSON Payload/get-resource.py b/Python/Endpoint Examples/JSON Payload/get-resource.py similarity index 100% rename from Python/JSON Payload/get-resource.py rename to Python/Endpoint Examples/JSON Payload/get-resource.py diff --git a/Python/JSON Payload/gif.py b/Python/Endpoint Examples/JSON Payload/gif.py similarity index 100% rename from Python/JSON Payload/gif.py rename to Python/Endpoint Examples/JSON Payload/gif.py diff --git a/Python/JSON Payload/html.py b/Python/Endpoint Examples/JSON Payload/html.py similarity index 100% rename from Python/JSON Payload/html.py rename to Python/Endpoint Examples/JSON Payload/html.py diff --git a/Python/JSON Payload/jpg.py b/Python/Endpoint Examples/JSON Payload/jpg.py similarity index 100% rename from Python/JSON Payload/jpg.py rename to Python/Endpoint Examples/JSON Payload/jpg.py diff --git a/Python/JSON Payload/linearized-pdf.py b/Python/Endpoint Examples/JSON Payload/linearized-pdf.py similarity index 100% rename from Python/JSON Payload/linearized-pdf.py rename to Python/Endpoint Examples/JSON Payload/linearized-pdf.py diff --git a/Python/JSON Payload/merged-pdf.py b/Python/Endpoint Examples/JSON Payload/merged-pdf.py similarity index 100% rename from Python/JSON Payload/merged-pdf.py rename to Python/Endpoint Examples/JSON Payload/merged-pdf.py diff --git a/Python/JSON Payload/pdf-info.py b/Python/Endpoint Examples/JSON Payload/pdf-info.py similarity index 100% rename from Python/JSON Payload/pdf-info.py rename to Python/Endpoint Examples/JSON Payload/pdf-info.py diff --git a/Python/JSON Payload/pdf-with-added-image.py b/Python/Endpoint Examples/JSON Payload/pdf-with-added-image.py similarity index 100% rename from Python/JSON Payload/pdf-with-added-image.py rename to Python/Endpoint Examples/JSON Payload/pdf-with-added-image.py diff --git a/Python/JSON Payload/pdf-with-imported-form-data.py b/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py similarity index 100% rename from Python/JSON Payload/pdf-with-imported-form-data.py rename to Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py diff --git a/Python/JSON Payload/pdf.py b/Python/Endpoint Examples/JSON Payload/pdf.py similarity index 100% rename from Python/JSON Payload/pdf.py rename to Python/Endpoint Examples/JSON Payload/pdf.py diff --git a/Python/JSON Payload/pdfa.py b/Python/Endpoint Examples/JSON Payload/pdfa.py similarity index 100% rename from Python/JSON Payload/pdfa.py rename to Python/Endpoint Examples/JSON Payload/pdfa.py diff --git a/Python/JSON Payload/pdfx.py b/Python/Endpoint Examples/JSON Payload/pdfx.py similarity index 100% rename from Python/JSON Payload/pdfx.py rename to Python/Endpoint Examples/JSON Payload/pdfx.py diff --git a/Python/JSON Payload/png.py b/Python/Endpoint Examples/JSON Payload/png.py similarity index 100% rename from Python/JSON Payload/png.py rename to Python/Endpoint Examples/JSON Payload/png.py diff --git a/Python/JSON Payload/restricted-pdf.py b/Python/Endpoint Examples/JSON Payload/restricted-pdf.py similarity index 100% rename from Python/JSON Payload/restricted-pdf.py rename to Python/Endpoint Examples/JSON Payload/restricted-pdf.py diff --git a/Python/JSON Payload/split-pdf.py b/Python/Endpoint Examples/JSON Payload/split-pdf.py similarity index 100% rename from Python/JSON Payload/split-pdf.py rename to Python/Endpoint Examples/JSON Payload/split-pdf.py diff --git a/Python/JSON Payload/tif.py b/Python/Endpoint Examples/JSON Payload/tif.py similarity index 100% rename from Python/JSON Payload/tif.py rename to Python/Endpoint Examples/JSON Payload/tif.py diff --git a/Python/JSON Payload/unrestricted-pdf.py b/Python/Endpoint Examples/JSON Payload/unrestricted-pdf.py similarity index 100% rename from Python/JSON Payload/unrestricted-pdf.py rename to Python/Endpoint Examples/JSON Payload/unrestricted-pdf.py diff --git a/Python/JSON Payload/upload.py b/Python/Endpoint Examples/JSON Payload/upload.py similarity index 100% rename from Python/JSON Payload/upload.py rename to Python/Endpoint Examples/JSON Payload/upload.py diff --git a/Python/JSON Payload/watermarked-pdf.py b/Python/Endpoint Examples/JSON Payload/watermarked-pdf.py similarity index 100% rename from Python/JSON Payload/watermarked-pdf.py rename to Python/Endpoint Examples/JSON Payload/watermarked-pdf.py diff --git a/Python/JSON Payload/zip.py b/Python/Endpoint Examples/JSON Payload/zip.py similarity index 100% rename from Python/JSON Payload/zip.py rename to Python/Endpoint Examples/JSON Payload/zip.py From 176a6d740801112538b003fccb974c173a69e034 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Fri, 27 Oct 2023 15:05:36 -0500 Subject: [PATCH 5/8] Add READMEs to all of the "Endpoint Example" directories --- DotNET/Endpoint Examples/README.md | 5 +++++ Java/Endpoint Examples/README.md | 5 +++++ JavaScript/Endpoint Examples/README.md | 5 +++++ PHP/Endpoint Examples/README.md | 5 +++++ Python/Endpoint Examples/README.md | 5 +++++ cURL/Endpoint Examples/README.md | 5 +++++ 6 files changed, 30 insertions(+) create mode 100644 DotNET/Endpoint Examples/README.md create mode 100644 Java/Endpoint Examples/README.md create mode 100644 JavaScript/Endpoint Examples/README.md create mode 100644 PHP/Endpoint Examples/README.md create mode 100644 Python/Endpoint Examples/README.md create mode 100644 cURL/Endpoint Examples/README.md diff --git a/DotNET/Endpoint Examples/README.md b/DotNET/Endpoint Examples/README.md new file mode 100644 index 0000000..69c034d --- /dev/null +++ b/DotNET/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find DotNET code examples to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. diff --git a/Java/Endpoint Examples/README.md b/Java/Endpoint Examples/README.md new file mode 100644 index 0000000..533132d --- /dev/null +++ b/Java/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find Java code examples to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. diff --git a/JavaScript/Endpoint Examples/README.md b/JavaScript/Endpoint Examples/README.md new file mode 100644 index 0000000..f68da9e --- /dev/null +++ b/JavaScript/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find JavaScript code examples to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. diff --git a/PHP/Endpoint Examples/README.md b/PHP/Endpoint Examples/README.md new file mode 100644 index 0000000..3c0ffdb --- /dev/null +++ b/PHP/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find PHP code examples to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. diff --git a/Python/Endpoint Examples/README.md b/Python/Endpoint Examples/README.md new file mode 100644 index 0000000..818e9be --- /dev/null +++ b/Python/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find Python code examples to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. diff --git a/cURL/Endpoint Examples/README.md b/cURL/Endpoint Examples/README.md new file mode 100644 index 0000000..0715b82 --- /dev/null +++ b/cURL/Endpoint Examples/README.md @@ -0,0 +1,5 @@ +Here you will find example cURL scripts to send calls to each of the individual endpoints supported by the pdfRest Cloud API service. + +Multipart Payload examples show how to send files and parameters directly to an endpoint for processing, using a multipart/form-data payload to separate files and parameters. + +JSON Payload examples show how to upload files with simple binary payloads and send streamlined, single part calls to processing endpoints using a JSON payload to specify resource IDs and parameters. From e85945a4d8d5d412e9442005f07e0fcd97d0a529 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Tue, 31 Oct 2023 11:01:41 -0500 Subject: [PATCH 6/8] Minor fixes - The /html route does not actually exist in production - Extra words got copied/moved into the pdf-info sample - Corrected imported data to call the right route - Clarify naming for zip since it can take literally anything --- Python/Endpoint Examples/JSON Payload/html.py | 23 ------------------- .../JSON Payload/pdf-info.py | 2 +- .../pdf-with-imported-form-data.py | 4 ++-- Python/Endpoint Examples/JSON Payload/zip.py | 8 +++---- 4 files changed, 7 insertions(+), 30 deletions(-) delete mode 100644 Python/Endpoint Examples/JSON Payload/html.py diff --git a/Python/Endpoint Examples/JSON Payload/html.py b/Python/Endpoint Examples/JSON Payload/html.py deleted file mode 100644 index 9e4f142..0000000 --- a/Python/Endpoint Examples/JSON Payload/html.py +++ /dev/null @@ -1,23 +0,0 @@ -import requests -import json - - -data = { - 'content': 'Web PageHello World!', - 'output': 'example_html_out' -} -print("Processing...") -response = requests.post(url='https://api.pdfrest.com/html', - data=json.dumps(data), - headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) - -print("HTML response status code: " + str(response.status_code)) - -if response.ok: - response_json = response.json() - print(json.dumps(response_json, indent = 2)) - - - -else: - print(response.text) diff --git a/Python/Endpoint Examples/JSON Payload/pdf-info.py b/Python/Endpoint Examples/JSON Payload/pdf-info.py index 74d92b8..8758146 100644 --- a/Python/Endpoint Examples/JSON Payload/pdf-info.py +++ b/Python/Endpoint Examples/JSON Payload/pdf-info.py @@ -18,7 +18,7 @@ uploaded_id = upload_response_json['files'][0]['id'] info_data = { "id" : uploaded_id, "queries": "title" } - print(json.dumps(info_data, indent = 2))Content-Filename + print(json.dumps(info_data, indent = 2)) print("Processing file...") diff --git a/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py b/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py index 8fcd012..f737f6f 100644 --- a/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py +++ b/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py @@ -32,12 +32,12 @@ uploaded_pdf_id = upload_pdf_response_json['files'][0]['id'] uploaded_data_id = upload_data_response_json['files'][0]['id'] - added_image_data = { "id" : uploaded_pdf_id, "data_id": uploaded_data_id } + added_image_data = { "id" : uploaded_pdf_id, "data__file_id": uploaded_data_id } print(json.dumps(added_image_data, indent = 2)) print("Processing file...") - added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-added-image', + added_image_response = requests.post(url='https://api.pdfrest.com/pdf-with-imported-form-data', data=json.dumps(added_image_data), headers={'Content-Type': 'application/json', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) diff --git a/Python/Endpoint Examples/JSON Payload/zip.py b/Python/Endpoint Examples/JSON Payload/zip.py index 2c83250..a6cc10b 100644 --- a/Python/Endpoint Examples/JSON Payload/zip.py +++ b/Python/Endpoint Examples/JSON Payload/zip.py @@ -1,24 +1,24 @@ import requests import json -with open('/path/to/first_file', 'rb') as f: +with open('/path/to/first_file', 'rb') as f: # Note that the full file name plus extension needs to be reflected in 'Content-Filename below' upload_first_file_data = f.read() print("Uploading first file...") upload_first_file_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_first_file_data, - headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'first_file.pdf', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'Content-Filename': 'first_file', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("First upload response status code: " + str(upload_first_file_response.status_code)) -with open('/path/to/second_file', 'rb') as f: +with open('/path/to/second_file', 'rb') as f: # Note that the full file name plus extension needs to be reflected in 'Content-Filename below' upload_second_file_data = f.read() print("Uploading second file...") upload_second_file_response = requests.post(url='https://api.pdfrest.com/upload', data=upload_second_file_data, - headers={'Content-Type': 'application/octet-stream', 'content-filename': 'second_file.png', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) + headers={'Content-Type': 'application/octet-stream', 'content-filename': 'second_file', "API-Key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}) print("Second upload response status code: " + str(upload_second_file_response.status_code)) From b93d6317186eda3323589539b4b349d4287f1e88 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Tue, 31 Oct 2023 11:07:25 -0500 Subject: [PATCH 7/8] Correct Python example README paths for the new structure --- Python/Endpoint Examples/JSON Payload/README.md | 2 +- Python/Endpoint Examples/Multipart Payload/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/Endpoint Examples/JSON Payload/README.md b/Python/Endpoint Examples/JSON Payload/README.md index 914a5af..2741a38 100644 --- a/Python/Endpoint Examples/JSON Payload/README.md +++ b/Python/Endpoint Examples/JSON Payload/README.md @@ -6,5 +6,5 @@ for accepted inputs, options, and other specifics about individual endpoints. Using Python3: -1. `cd Python/` +1. `cd 'Python/Endpoint Examples/JSON Payload/` 2. `python name-of-sample-program.py` diff --git a/Python/Endpoint Examples/Multipart Payload/README.md b/Python/Endpoint Examples/Multipart Payload/README.md index 914a5af..647c252 100644 --- a/Python/Endpoint Examples/Multipart Payload/README.md +++ b/Python/Endpoint Examples/Multipart Payload/README.md @@ -6,5 +6,5 @@ for accepted inputs, options, and other specifics about individual endpoints. Using Python3: -1. `cd Python/` +1. `cd 'Python/Endpoint Examples/Multipart Payload/` 2. `python name-of-sample-program.py` From 9e9199a0a51cfc9be00a1b5bdfb70b6451110254 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Tue, 31 Oct 2023 11:48:23 -0500 Subject: [PATCH 8/8] More small tweaks --- Python/Endpoint Examples/JSON Payload/README.md | 2 +- .../JSON Payload/pdf-with-imported-form-data.py | 2 +- Python/Endpoint Examples/Multipart Payload/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Python/Endpoint Examples/JSON Payload/README.md b/Python/Endpoint Examples/JSON Payload/README.md index 2741a38..a9dbe2c 100644 --- a/Python/Endpoint Examples/JSON Payload/README.md +++ b/Python/Endpoint Examples/JSON Payload/README.md @@ -6,5 +6,5 @@ for accepted inputs, options, and other specifics about individual endpoints. Using Python3: -1. `cd 'Python/Endpoint Examples/JSON Payload/` +1. `cd 'Python/Endpoint Examples/JSON Payload/'` 2. `python name-of-sample-program.py` diff --git a/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py b/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py index f737f6f..0c63b0a 100644 --- a/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py +++ b/Python/Endpoint Examples/JSON Payload/pdf-with-imported-form-data.py @@ -32,7 +32,7 @@ uploaded_pdf_id = upload_pdf_response_json['files'][0]['id'] uploaded_data_id = upload_data_response_json['files'][0]['id'] - added_image_data = { "id" : uploaded_pdf_id, "data__file_id": uploaded_data_id } + added_image_data = { "id" : uploaded_pdf_id, "data_file_id": uploaded_data_id } print(json.dumps(added_image_data, indent = 2)) diff --git a/Python/Endpoint Examples/Multipart Payload/README.md b/Python/Endpoint Examples/Multipart Payload/README.md index 647c252..7145956 100644 --- a/Python/Endpoint Examples/Multipart Payload/README.md +++ b/Python/Endpoint Examples/Multipart Payload/README.md @@ -6,5 +6,5 @@ for accepted inputs, options, and other specifics about individual endpoints. Using Python3: -1. `cd 'Python/Endpoint Examples/Multipart Payload/` +1. `cd 'Python/Endpoint Examples/Multipart Payload/'` 2. `python name-of-sample-program.py`