Codumentor logo Codumentor Enterprise

PDF Editor Plugin

Lets the agent open, read, and fill PDF files (.pdf) in the conversation — including interactive forms (AcroForm), with flattening, incremental saves for signed documents, XFA detection, page rendering for visual inspection, and a sandboxed pdf_python escape hatch. Saved files show a download card in the transcript (served by the Files plugin).

Editing and form filling need no external software — pypdf is bundled. Page rendering uses an optional rasteriser (see below).

Configuration

plugins:
  - module: codumentor.plugins.pdf_editor
    class: PdfEditorPlugin
    args:
      enabled: true
      target_agents: "main"  # "main", "subagent", or "all" (default: "main")

Keep Files enabled so download cards in the transcript resolve. Without it, save cards still render but their links 404.

Parameters

KeyTypeDefaultDescription
enabledbooltrueMaster switch.
target_agentsstring"main"Which agents get the tools: "main", "subagent", or "all". Any other value is treated as "all".

Optional PDF rendering

Editing does not require any rasteriser. Rendering pages as images requires
pdftoppm (poppler-utils, preferred), mutool (mupdf-tools, AGPL — needs a
licence review) or LibreOffice in the server runtime, discovered when the
plugin loads; restart the service after installation. Unlike the office
editors, any of the three enables pdf_render — LibreOffice is not
required. Admin → Server reports cached discovery, not sandbox execution
verification. In containers install in the server image/container, not just
its host.
See PDF rendering (rasteriser)
for details, and the
office prerequisites
for installation scope and confinement.

What the agent can do

pdf_open is always available. After a PDF is open, the editing tools below appear; pdf_close removes them.

Maximum file size is 50 MB; encrypted (password-protected) PDFs cannot be opened. One PDF at a time; replace=true closes the open one first when it has no unsaved changes.

ToolWhenDescription
pdf_openalwaysOpen a .pdf (repo or attached folder); optionally copy to output_path first. Reports page count, form summary (field counts, signature fields, XFA class)
pdf_read_textopenText layer per page; textless pages are reported as probably scanned
pdf_list_fieldsopenField inventory: name, type, value, allowed values (checkbox on-state, radio exports, choice options), page/rect, read-only/required/hidden, max length, multiline
pdf_fill_fieldsopenFill by name; validated all-or-nothing before writing (unknown names get closest-match hints)
pdf_saveopenSave (atomic); flatten=true bakes values and removes the fields (refused for signed documents); signed documents save incrementally; download card
pdf_closeopenClose; refuses over unsaved changes unless save_first=true or discard_changes=true
pdf_renderopen, or standalone with file_pathPage images of the live state (unsaved edits included) or of any workspace PDF without opening it; at most 6 pages per call (pages: "1-3"); absent when no rasteriser is found at load
pdf_pythonopenEscape hatch: sandboxed pypdf against the live document (see below)

While a PDF is open the agent also receives a short workflow note — list fields before filling, never guess a field's meaning when a render would show the label, check fills with pdf_render, report fields left empty. It costs nothing in conversations that never open a PDF.

Forms

Field values are validated before anything is written: one invalid entry fails the call and nothing is written. Checkboxes take true/false (mapped to the field's real on-state, e.g. /Yes); radio groups take one of their export values; choices validate against their options (a list for multi-select); text fields respect max length. Read-only and signature fields are refused.

flatten=true bakes the filled values into the page content and removes the AcroForm entirely — the result is not editable. A signed document (a value-bearing signature field) is refused flattening and is instead saved incrementally: the original bytes stay a prefix, so existing signatures remain valid.

XFA forms are detected, not filled: hybrid forms (AcroForm + XFA) fill with a warning that Acrobat shows the XFA layer and may ignore the values; XFA-only forms refuse listing and filling, and pdf_render notes that their image is the static "Please wait…" placeholder.

The pdf_python escape hatch

pdf_python runs sandboxed Python against the live document, bound as writer (a pypdf PdfWriter) with pages (writer.pages) and a fresh read-only reader beside it; bindings persist between calls until the document closes. Good for rotating/deleting pages (pages[0].rotate(90), writer.remove_page(1)), metadata (writer.add_metadata({...})), bookmarks (writer.add_outline_item(...)), annotations (from pypdf.annotations import FreeText) and inspecting raw field dictionaries. Imports are restricted to allowlisted pypdf authoring modules (pypdf.generic, pypdf.annotations, pypdf.constants, …); PdfReader/PdfWriter/PdfMerger and the file-I/O modules are excluded, and open/exec/dunder access are refused.

It is not a page-content editor: changing existing text means rewriting content streams, which pypdf does not support. Every structural change should be checked with pdf_render.

At save time the session's additions are compared against the opened document: a newly added JavaScript or launch action (/JavaScript, /JS, /Launch, /SubmitForm) refuses the save; other new actions (e.g. /URI links) and embedded files are listed in the result. Pre-existing content is untouched and not re-reported. Pass capabilities=true for a read-only JSON manifest of the namespace.

See also