{
  "id": "pdf.edit",
  "object": "tool",
  "name": "Edit PDF",
  "summary": "Add text, images, boxes and lines.",
  "description": "Applies a list of edits to a PDF, in order: text (any of the 14 standard fonts, with colour, wrapping and opacity), images (a PNG or JPEG signature, stamp or logo), rectangles, lines and highlights. Positions are measured from the top-left of the page as it's displayed (rotated pages are handled), in points or as fractions of the page. Use it to sign a contract, fill in a PDF that has no form fields, or annotate a page. A filled box only covers content visually: the text underneath is still in the file and can be copied out. To really remove text, use text.redact or file.sanitize.",
  "category": "documents",
  "hosted_by": "Opentools",
  "runtime": "worker",
  "side_effects": false,
  "status": "live",
  "credits": 1,
  "price": "$0.0010",
  "providers": [
    {
      "id": "opentools",
      "name": "Opentools",
      "price": "$0.0010"
    }
  ],
  "mcp_name": "pdf_edit",
  "input_schema": {
    "type": "object",
    "properties": {
      "file": {
        "anyOf": [
          {
            "type": "object",
            "properties": {
              "url": {
                "type": "string",
                "format": "uri",
                "description": "Public http(s) URL of the file"
              }
            },
            "required": [
              "url"
            ]
          },
          {
            "type": "object",
            "properties": {
              "file_id": {
                "type": "string",
                "format": "uuid",
                "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                "description": "An id returned by POST /v1/files"
              }
            },
            "required": [
              "file_id"
            ]
          },
          {
            "type": "object",
            "properties": {
              "base64": {
                "type": "string",
                "description": "Base64-encoded file bytes (up to 10 MB)"
              },
              "name": {
                "type": "string",
                "description": "File name, e.g. invoice.pdf"
              },
              "content_type": {
                "type": "string"
              }
            },
            "required": [
              "base64",
              "name"
            ]
          },
          {
            "type": "object",
            "properties": {
              "connection": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "description": "A storage connection id or name (see storage.connections)"
              },
              "path": {
                "type": "string",
                "minLength": 1,
                "maxLength": 1024,
                "description": "Path of the file in that connection, e.g. reports/q3.pdf"
              }
            },
            "required": [
              "connection",
              "path"
            ]
          }
        ],
        "x-file": true,
        "description": "The PDF"
      },
      "edits": {
        "minItems": 1,
        "maxItems": 500,
        "type": "array",
        "items": {
          "oneOf": [
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "text"
                },
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000,
                  "description": "Page number, 1-based"
                },
                "units": {
                  "default": "pt",
                  "description": "pt: positions and sizes in points (72 per inch); fraction: 0-1 of the page width and height",
                  "type": "string",
                  "enum": [
                    "pt",
                    "fraction"
                  ]
                },
                "opacity": {
                  "default": 1,
                  "description": "0 (invisible) to 1 (solid)",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the text's top-left corner from the left edge of the page as displayed"
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the text's top-left corner from the top edge of the page as displayed"
                },
                "text": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 10000,
                  "description": "Text to write (Latin characters). Newlines start a new line."
                },
                "size": {
                  "default": 12,
                  "description": "Font size in points",
                  "type": "number",
                  "minimum": 2,
                  "maximum": 400
                },
                "color": {
                  "default": "#000000",
                  "description": "Text colour like #000000",
                  "type": "string",
                  "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "font": {
                  "default": "Helvetica",
                  "description": "One of the 14 standard PDF fonts",
                  "type": "string",
                  "enum": [
                    "Helvetica",
                    "Helvetica-Bold",
                    "Helvetica-Oblique",
                    "Helvetica-BoldOblique",
                    "Times-Roman",
                    "Times-Bold",
                    "Times-Italic",
                    "Times-BoldItalic",
                    "Courier",
                    "Courier-Bold",
                    "Courier-Oblique",
                    "Courier-BoldOblique",
                    "Symbol",
                    "ZapfDingbats"
                  ]
                },
                "max_width": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Wrap lines to this width. No wrapping if omitted."
                },
                "line_height": {
                  "default": 1.2,
                  "description": "Line spacing as a multiple of the font size",
                  "type": "number",
                  "minimum": 0.5,
                  "maximum": 5
                }
              },
              "required": [
                "type",
                "page",
                "x",
                "y",
                "text"
              ]
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "image"
                },
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000,
                  "description": "Page number, 1-based"
                },
                "units": {
                  "default": "pt",
                  "description": "pt: positions and sizes in points (72 per inch); fraction: 0-1 of the page width and height",
                  "type": "string",
                  "enum": [
                    "pt",
                    "fraction"
                  ]
                },
                "opacity": {
                  "default": 1,
                  "description": "0 (invisible) to 1 (solid)",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the image's top-left corner from the left edge of the page as displayed"
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the image's top-left corner from the top edge of the page as displayed"
                },
                "image": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "url": {
                          "type": "string",
                          "format": "uri",
                          "description": "Public http(s) URL of the file"
                        }
                      },
                      "required": [
                        "url"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "file_id": {
                          "type": "string",
                          "format": "uuid",
                          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
                          "description": "An id returned by POST /v1/files"
                        }
                      },
                      "required": [
                        "file_id"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "base64": {
                          "type": "string",
                          "description": "Base64-encoded file bytes (up to 10 MB)"
                        },
                        "name": {
                          "type": "string",
                          "description": "File name, e.g. invoice.pdf"
                        },
                        "content_type": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "base64",
                        "name"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "connection": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64,
                          "description": "A storage connection id or name (see storage.connections)"
                        },
                        "path": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 1024,
                          "description": "Path of the file in that connection, e.g. reports/q3.pdf"
                        }
                      },
                      "required": [
                        "connection",
                        "path"
                      ]
                    }
                  ],
                  "x-file": true,
                  "description": "PNG or JPEG, e.g. a signature or a stamp. PNG transparency is kept."
                },
                "width": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Width of the placed image"
                },
                "height": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Height. Keeps the image's aspect ratio if omitted."
                }
              },
              "required": [
                "type",
                "page",
                "x",
                "y",
                "image",
                "width"
              ]
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "rect"
                },
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000,
                  "description": "Page number, 1-based"
                },
                "units": {
                  "default": "pt",
                  "description": "pt: positions and sizes in points (72 per inch); fraction: 0-1 of the page width and height",
                  "type": "string",
                  "enum": [
                    "pt",
                    "fraction"
                  ]
                },
                "opacity": {
                  "default": 1,
                  "description": "0 (invisible) to 1 (solid)",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the box's top-left corner from the left edge of the page as displayed"
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the box's top-left corner from the top edge of the page as displayed"
                },
                "width": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Box width"
                },
                "height": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Box height"
                },
                "fill": {
                  "description": "Fill colour. Black if neither fill nor stroke is given.",
                  "type": "string",
                  "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "stroke": {
                  "description": "Outline colour. No outline if omitted.",
                  "type": "string",
                  "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "stroke_width": {
                  "default": 1,
                  "description": "Outline width in points",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100
                }
              },
              "required": [
                "type",
                "page",
                "x",
                "y",
                "width",
                "height"
              ]
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "line"
                },
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000,
                  "description": "Page number, 1-based"
                },
                "units": {
                  "default": "pt",
                  "description": "pt: positions and sizes in points (72 per inch); fraction: 0-1 of the page width and height",
                  "type": "string",
                  "enum": [
                    "pt",
                    "fraction"
                  ]
                },
                "opacity": {
                  "default": 1,
                  "description": "0 (invisible) to 1 (solid)",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "x1": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Start, from the left edge"
                },
                "y1": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Start, from the top edge"
                },
                "x2": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "End, from the left edge"
                },
                "y2": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "End, from the top edge"
                },
                "color": {
                  "default": "#000000",
                  "description": "Line colour",
                  "type": "string",
                  "pattern": "^#[0-9a-fA-F]{6}$"
                },
                "thickness": {
                  "default": 1,
                  "description": "Line width in points",
                  "type": "number",
                  "minimum": 0.1,
                  "maximum": 100
                }
              },
              "required": [
                "type",
                "page",
                "x1",
                "y1",
                "x2",
                "y2"
              ]
            },
            {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "highlight"
                },
                "page": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100000,
                  "description": "Page number, 1-based"
                },
                "units": {
                  "default": "pt",
                  "description": "pt: positions and sizes in points (72 per inch); fraction: 0-1 of the page width and height",
                  "type": "string",
                  "enum": [
                    "pt",
                    "fraction"
                  ]
                },
                "opacity": {
                  "default": 0.35,
                  "description": "0 (invisible) to 1 (solid)",
                  "type": "number",
                  "minimum": 0,
                  "maximum": 1
                },
                "x": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the highlight's top-left corner from the left edge of the page as displayed"
                },
                "y": {
                  "type": "number",
                  "minimum": 0,
                  "maximum": 100000,
                  "description": "Distance of the highlight's top-left corner from the top edge of the page as displayed"
                },
                "width": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Highlight width"
                },
                "height": {
                  "type": "number",
                  "exclusiveMinimum": 0,
                  "maximum": 100000,
                  "description": "Highlight height"
                },
                "color": {
                  "default": "#FFEB3B",
                  "description": "Highlight colour",
                  "type": "string",
                  "pattern": "^#[0-9a-fA-F]{6}$"
                }
              },
              "required": [
                "type",
                "page",
                "x",
                "y",
                "width",
                "height"
              ]
            }
          ]
        },
        "description": "Edits to apply, in order. Later edits draw on top."
      }
    },
    "required": [
      "file",
      "edits"
    ]
  },
  "kind": "tool"
}