Skip to main content
POST
/
pdf-editor
/
edit
/
reparse
Edit PDF
curl --request POST \
  --url https://dev.platformbackend.unsiloed.ai/api/v1/pdf-editor/edit/reparse \
  --header 'Content-Type: multipart/form-data' \
  --header 'api-key: <api-key>' \
  --form 'edit_request=<string>' \
  --form file=@example-file
{
  "success": true,
  "message": "<string>",
  "pdf_url": "<string>",
  "original_size": 123,
  "edited_size": 123,
  "items_processed": 123,
  "reparsed": true,
  "new_job_id": "<string>"
}

Overview

The PDF Editor endpoint allows you to modify PDF documents by replacing text and images at specific coordinates. The endpoint supports both text and image replacements, and automatically re-parses the edited document to provide updated analysis results.

Try it

curl -X POST "https://dev.platformbackend.unsiloed.ai/api/v1/pdf-editor/edit/reparse" \
  -H "api-key: your-api-key" \
  -F "file=@test.pdf" \
  -F 'edit_request={
    "items": [
      {
        "type": "text",
        "page_number": 1,
        "bbox": {"left": 100, "top": 150, "width": 200, "height": 30},
        "replacement_text": "Updated Text"
      }
    ]
  }'

Advanced Usage with Image Uploads

When working with image replacements, you can upload image files directly:
Python
import requests
import json

url = "https://dev.platformbackend.unsiloed.ai/api/v1/pdf-editor/edit/reparse"
headers = {"api-key": "your-api-key"}

# Prepare edit request with image file reference
edit_request = {
    "items": [
        {
            "type": "image",
            "page_number": 1,
            "bbox": {
                "left": 200,
                "top": 300,
                "width": 150,
                "height": 100
            },
            "image_file": "logo.png"  # Reference to uploaded file
        }
    ]
}

# Prepare files
files = {
    "file": ("document.pdf", open("document.pdf", "rb"), "application/pdf"),
    "image_files": ("logo.png", open("logo.png", "rb"), "image/png")
}

data = {
    "edit_request": json.dumps(edit_request),
    "upload_to_storage": "true"
}

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

Checking Parse Task Status

After editing and re-parsing a PDF, you can monitor the parsing progress using the task status endpoint.

Endpoint

GET https://prod.visionapi.unsiloed.ai/parse/{task_id}

How to Check Status

Python
import requests
import time

def check_task_status(task_id, api_key):
    """Check the status of a parsing task"""
    url = f"https://prod.visionapi.unsiloed.ai/parse/{task_id}"
    headers = {"api-key": api_key}
    
    response = requests.get(url, headers=headers)
    
    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Error checking status: {response.status_code}")

# Example usage
api_key = "your-api-key"
task_id = "e77a5c42-4dc1-44d0-a30e-ed191e8a8908"  # From edit response

status_data = check_task_status(task_id, api_key)
print(f"Status: {status_data['status']}")
JavaScript
async function checkTaskStatus(taskId, apiKey) {
  const url = `https://prod.visionapi.unsiloed.ai/parse/${taskId}`;
  
  const response = await fetch(url, {
    method: 'GET',
    headers: {
      'api-key': apiKey
    }
  });
  
  if (response.ok) {
    return await response.json();
  } else {
    throw new Error(`Error checking status: ${response.status}`);
  }
}

// Example usage
const apiKey = 'your-api-key';
const taskId = 'e77a5c42-4dc1-44d0-a30e-ed191e8a8908'; // From edit response

const statusData = await checkTaskStatus(taskId, apiKey);
console.log(`Status: ${statusData.status}`);
cURL
curl -X 'GET' \
  'https://prod.visionapi.unsiloed.ai/parse/e77a5c42-4dc1-44d0-a30e-ed191e8a8908' \
  -H 'accept: application/json' \
  -H 'api-key: your-api-key'

Task Status Values

  • Pending: Task is queued and waiting to be processed
  • Processing: Task is currently being parsed
  • Succeeded: Parsing completed successfully, results are available
  • Failed: Parsing failed, check error message in response

Authorizations

api-key
string
header
required

Body

multipart/form-data
file
file
required

PDF file to edit

edit_request
string
required

JSON string containing list of edit items with bounding box coordinates and replacement content

image_files
file[]

Optional list of image files to upload and use for image replacements

Response

PDF edited successfully

success
boolean

Whether the PDF edit operation was successful

message
string

Status message about the edit operation

pdf_url
string

URL of the edited PDF file (if upload_to_storage is true)

original_size
number

Size of the original PDF file in bytes

edited_size
number

Size of the edited PDF file in bytes

items_processed
number

Number of edit items that were processed

reparsed
boolean

Whether the edited PDF was submitted for re-parsing

new_job_id
string

New job ID for monitoring the re-parsing progress (if job_id was provided)