Skip to main content
The edit.run() method fills PDF forms and modifies DOCX documents programmatically.

Basic Usage

import Reducto from 'reductoai';
import fs from 'fs';

const client = new Reducto();

// Upload a form
const upload = await client.upload({ 
  file: fs.createReadStream("application.pdf") 
});

// Fill the form with instructions
const result = await client.edit.run({
  document_url: upload.file_id,
  edit_instructions: "Fill in the form with: name='John Doe', email='[email protected]', date='12/25/2024'"
});

// Download the filled form
const filledPdfUrl = result.document_url;

Method Signatures

Synchronous Edit

edit.run(params: {
  document_url: string | Upload;
  edit_instructions: string;
  edit_options?: {
    color?: string;
    enable_overflow_pages?: boolean;
    llm_provider_preference?: "openai" | "anthropic" | "google" | null;
  };
  form_schema?: Array<{
    bbox: BoundingBox;
    description: string;
    type: "text" | "checkbox" | "dropdown" | "barcode";
    fill?: boolean;
    value?: string | null;
  }> | null;
  priority?: boolean;
}, options?: RequestOptions): Promise<EditResponse>

Asynchronous Edit

edit.runJob(params: {
  document_url: string | Upload;
  edit_instructions: string;
  edit_options?: {
    color?: string;
    enable_overflow_pages?: boolean;
    llm_provider_preference?: "openai" | "anthropic" | "google" | null;
  };
  form_schema?: Array<{
    bbox: BoundingBox;
    description: string;
    type: "text" | "checkbox" | "dropdown" | "barcode";
    fill?: boolean;
    value?: string | null;
  }> | null;
  priority?: boolean;
  webhook?: WebhookConfigNew;
}, options?: RequestOptions): Promise<EditRunJobResponse>

Form Schema

For PDF forms, you can provide a schema with bounding boxes:
const result = await client.edit.run({
  document_url: upload.file_id,
  edit_instructions: "Fill the form with the provided data",
  form_schema: [
    {
      bbox: { left: 100, top: 200, width: 200, height: 30, page: 1 },
      description: "Name field",
      type: "text",
      value: "John Doe"
    },
    {
      bbox: { left: 100, top: 250, width: 200, height: 30, page: 1 },
      description: "Email field",
      type: "text",
      value: "[email protected]"
    }
  ]
});

Next Steps