redact_pdf
Permanently remove text, images, and drawings under specified areas, words, or patterns from a PDF, then save a redacted copy with sensitive matches replaced in metadata and comments.
Instructions
Redact a PDF for real: write a copy (default "_redacted.pdf") from which the text, pictures and drawings under the redacted areas are removed, not just covered. Say what to redact with any of:
texts: words or phrases, found as search_text finds them (match_case, whole_word);
patterns: Python regular expressions, e.g. "[\w.+-]+@[\w-]+.[\w.]+" for email addresses (ignoring case unless match_case);
areas: [{"page": 1, "rect": [left, bottom, right, top]}] in PDF points, in the page's own coordinates (as search_text gives rectangles), e.g. for a signature. pages limits where texts and patterns are searched (default all). Every character whose centre is in an area is removed; pictures have the pixels there blanked; drawings wholly inside are removed; annotations touching an area are removed (a form field entirely, with its value). Areas are painted over in fill ("black", "white", or "none"). The texts and patterns are also replaced with "[redacted]" in metadata, bookmarks, comments, form values and alt text anywhere in the file.
Each rewritten page is read back to confirm nothing is left under an area and nothing else changed. A page that can't be redacted exactly (e.g. a font without widths, a picture in JPEG 2000, JBIG2 or CCITT, or a failed check) is replaced by a picture of itself at dpi (72-300) with the areas painted over, so its text can no longer be selected; rasterize="never" refuses such pages instead, "always" rasterizes every redacted page. pages_without_text lists searched pages with no text (scans): their words are pictures, so redact them with areas, or run ocr_pdf first so texts and patterns find them. originals_kept counts pictures or forms redacted here that other pages still show unredacted. Attachments can't be searched; remove them with sanitize_pdf. Needs the owner password if the PDF forbids changes, or forbids changing comments and one is in an area. Signed PDFs are refused. Check the result with view_pages, and search_text on it, before sharing.
Any password argument can be "ask": the user then types it on a local page, so it never passes through the chat.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"input_path": "<input_path>"
},
"name": "redact_pdf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dpi | No | ||
| fill | No | black | |
| areas | No | ||
| pages | No | ||
| texts | No | ||
| password | No | ||
| patterns | No | ||
| overwrite | No | ||
| rasterize | No | if_needed | |
| input_path | Yes | ||
| match_case | No | ||
| whole_word | No | ||
| output_path | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | Yes | ||
| output | Yes | ||
| matches | Yes | ||
| match_count | Yes | ||
| originals_kept | Yes | ||
| pages_searched | Yes | ||
| also_redacted_in | Yes | ||
| alt_text_removed | Yes | ||
| matches_truncated | Yes | ||
| pages_without_text | Yes | ||
| password_protected | Yes | ||
| user_password_changed | Yes | ||
| permissions_restricted | Yes | ||
| attachments_not_searched | Yes |