Skip to main content
Glama
pdf4me
by pdf4me

replace_text_with_image

Replace specific text in a PDF with an image. Provide the PDF, image, text to find, and page range to place the image exactly where the text occurs.

Instructions

Replace occurrences of a text string in a PDF with an image using the PDF4me ReplaceTextWithImage API (POST /api/v2/ReplaceTextWithImage). Provide the PDF path, image path, text to replace, page sequence (e.g. all, 1, 1,3,5, 2-5), and image width/height in pixels. Supports async via isAsync and 202 Location polling. Optional output directory and file name.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
file_pathYesLocal path to the input PDF.
output_dirNo
image_widthNoDisplay width of the placed image in pixels (API integer).
image_heightNoDisplay height of the placed image in pixels (API integer).
replace_textYesLiteral text in the PDF to replace with the image.
page_sequenceNoPages to search (e.g. "all", "1", "1,3,5", "2-5").all
image_file_pathYesLocal path to the replacement image (e.g. PNG, JPG).
output_file_nameNo
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden of behavioral disclosure. It discloses async support and the API endpoint, which is useful context. However, it does not state whether the original PDF is modified in place or a new file is created, and it does not describe the return value or output format. The mention of 'Optional output directory and file name' implies a new output file but does not confirm behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single dense sentence that conveys the main action, required inputs, page sequence format, async behavior, and optional output. It is not overly long and contains no filler, but the run-on structure could be improved for readability. Every piece of information is relevant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (8 parameters, 3 required) and no output schema, the description covers the core purpose and inputs but leaves gaps: it does not explain what happens after the operation (return value, output file details), whether the original is preserved, or how to handle the 202 Location polling result. It also does not clarify which file formats are accepted for the image beyond the schema's PNG/JPG hint.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 75% (6 of 8 parameters have descriptions). The description repeats the parameter list and adds page sequence examples that are already in the schema description. It mentions 'image width/height in pixels,' which the schema already states. The description references 'isAsync' but this parameter is not present in the schema, adding confusion rather than clarifying parameter semantics.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action: 'Replace occurrences of a text string in a PDF with an image.' This is a specific verb+resource combination that distinguishes it from sibling tools like find_and_replace_text (text-only replacement) and replace_text_with_image_in_word (Word documents). The mention of the PDF4me API endpoint adds technical specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides usage context by listing required inputs (PDF path, image path, text to replace) and page sequence examples (all, 1, 1,3,5, 2-5). It also mentions async support via isAsync and 202 Location polling, which helps the agent know how to handle long-running operations. However, it does not explicitly name alternative tools or when-not-to-use scenarios, though the purpose implies when this tool is appropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pdf4me/pdf4me-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server