06 Extract Document Text
Extract text from a stored document and feed it into your workflow
- session
- document_id_link
- json
- text
- text_length
- success
- refresh
- text_items
- selectable_items
- indexed_items
- item_count
ComfyUI-ZMongo stores documents - some created from text directly, some uploaded as PDFs, DOCX, or scanned files with real file payloads. 06 Extract Document Text is the node that pulls the text out of a stored document so you can use it in your graph: feed it to an LLM node, a prompt builder, a router, whatever consumes strings.
It needs a session (the ZMONGO_API_SESSION), the document_id of the target, and a save toggle (default true) that tells the backend whether to persist the extracted text back onto the document. document_prefix defaults to /documents. The call goes to the backend's /api/extract-text/{id} endpoint; when a document has a file payload (PDF/DOCX/OCR-able), that's where the real extraction happens server-side.
The fallback that saves you
Here's the design detail worth knowing: if the selected document has no file payload - which is the normal state for documents created by 06 Create Text Document - the extraction endpoint returns nothing useful. Rather than failing, the node detects that and falls back to fetching the document's stored text via /api/text/{id}. So Extract Text works on both file-backed documents (real extraction) and text-created documents (returns the stored string). The json output tells you which path ran (source: stored_text_fallback vs. an extraction result), which is exactly the kind of transparency that prevents "why is this empty?" debugging sessions.
Inputs and outputs that matter
document_id plus the optional document_id_link (* type) - the link is preferred when both are wired. save decides whether the backend writes the extracted text back. On the output side: text is the string you actually want, text_length is a quick sanity check, success is your flag, refresh the dirty token, and text_items / selectable_items / indexed_items / item_count feed the list-selection pattern.
Honest caveats
The checks array in the json output is worth reading when extraction fails - it'll tell you to use this node only for file-backed documents when you need real file extraction, and to prefer 06 Get Document Text for text-created ones. This is a backend round-trip, so unlike the pure in-memory content-pack nodes it needs a working session; and heavy PDFs go through PyMuPDF on the server, which the README's install step calls out (pip install pymupdf python-docx). Keep save: true only when you actually want the extracted text cached back onto the record.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| document_id | STRING | — | |
| save | BOOLEAN | true | — |
| document_prefix | STRING | /documents | — |
| document_id_linkopt | * | — | |
| refresh_tokenopt | STRING | — |
Outputs (9)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| text | STRING | — |
| text_length | INT | — |
| success | BOOLEAN | — |
| refresh | STRING | — |
| text_items | * | — |
| selectable_items | * | — |
| indexed_items | STRING | — |
| item_count | INT | — |