几分钟内开始转换 PDF
针对开发者的快速入门指南
01
02
发起您的第一个请求
上传 PDF 文件并立即获得可编辑的 PPTX 任务。转换过程自动执行。
python
import requests
url = "https://api.pdf.beauty/api/convert/submit"
files = {"file": open("presentation.pdf", "rb")}
headers = {"Authorization": "pk_xxxxxxxxxxxxx"}
response = requests.post(url, files=files, headers=headers)
task_id = response.json()["taskId"]
print(f"Task created: {task_id}")03
轮询完成状态
检查任务状态直到转换完成。完成后即可下载您的 PPTX 文件。
python
import time
# Poll for task completion
while True:
status = requests.get(
f"https://api.pdf.beauty/api/convert/tasks/{task_id}",
headers=headers
).json()
if status["status"] == "completed":
print(f"Download: {status['resultUrl']}")
break
elif status["status"] == "failed":
print(f"Error: {status['error']}")
break
time.sleep(2)