fill_forms
Fill existing form fields in a PDF document by providing field names, page numbers, and text values. Use 'read_pdf_forms_info' to retrieve field names first.
Instructions
Fill existing form fields in a PDF document.
Example fields format:
[
{
"fieldName": "field_name_from_form_info",
"pages": "1",
"text": "Value to fill"
}
]
Use 'read_pdf_forms_info' first to get the fieldName values of the form.
Ref: https://developer.pdf.co/api-reference/pdf-add#create-fillable-pdf-forms.mdInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files. | |
| fields | Yes | List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties. | |
| name | No | File name for the generated output. (Optional) | |
| httpusername | No | HTTP auth user name if required to access source url. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- pdfco/mcp/tools/apis/form.py:41-88 (handler)The tool handler function 'fill_pdf_forms' registered as 'fill_forms'. It receives a URL, a list of fields with fieldName/pages/text, and optional parameters, then calls fill_pdf_form_fields service function.
@mcp.tool(name="fill_forms") async def fill_pdf_forms( url: str = Field( description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files." ), fields: list = Field( description="List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties." ), name: str = Field( description="File name for the generated output. (Optional)", default="" ), httpusername: str = Field( description="HTTP auth user name if required to access source url. (Optional)", default="", ), httppassword: str = Field( description="HTTP auth password if required to access source url. (Optional)", default="", ), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: """ Fill existing form fields in a PDF document. Example fields format: [ { "fieldName": "field_name_from_form_info", "pages": "1", "text": "Value to fill" } ] Use 'read_pdf_forms_info' first to get the fieldName values of the form. Ref: https://developer.pdf.co/api-reference/pdf-add#create-fillable-pdf-forms.md """ params = ConversionParams( url=url, httpusername=httpusername, httppassword=httppassword, name=name, ) return await fill_pdf_form_fields(params, fields=fields, api_key=api_key) - pdfco/mcp/tools/apis/form.py:37-41 (schema)Input parameters for fill_forms tool: url (str), fields (list of dicts with fieldName/pages/text), name (str, optional), httpusername/httppassword (str, optional), api_key (str, optional). All defined via pydantic Field descriptors.
return await get_pdf_form_fields_info(params, api_key=api_key) @mcp.tool(name="fill_forms") - pdfco/mcp/tools/apis/form.py:41-41 (registration)Tool registration via @mcp.tool(name='fill_forms') decorator on the fill_pdf_forms async function.
@mcp.tool(name="fill_forms") - pdfco/mcp/services/pdf.py:32-45 (helper)The service function 'fill_pdf_form_fields' which constructs the payload with fields and annotations and sends a POST request to 'pdf/edit/add' endpoint.
async def fill_pdf_form_fields( params: ConversionParams, fields: list | None = None, annotations: list | None = None, api_key: str | None = None, ) -> BaseResponse: custom_payload = {} if fields: custom_payload["fields"] = fields if annotations: custom_payload["annotations"] = annotations return await request( "pdf/edit/add", params, custom_payload=custom_payload, api_key=api_key )