06 Ingest Text PDF / DOCX
Turn a PDF or DOCX into a searchable database record
- session
- file_path_link
- json
- document_id
- document_id_link
- document_name
- filename_link
- text
- text_length
- local_limit_bytes
- success
- refresh
- document_ids
- text_items
- selectable_items
- indexed_items
- item_count
This is the node that makes ZMongo actually useful for real-world documents. "06 Ingest Text PDF / DOCX" reads a local PDF, DOCX, or plain-text file, extracts the text on your machine, and saves it as a structured database record with metadata, tags, and source-file info. No cloud upload, no API call - the extraction happens locally with PyMuPDF (PDF) and python-docx (DOCX), and it maps the result into a document payload including line counts and byte sizes. It's how you build a document library ComfyUI can then query, summarize, or feed to an LLM.
How it works
Point file_path at the file (or wire file_path_link from "06 Document File Browser"), and it:
- Extracts text locally -
pymupdffor PDFs,python-docxfor DOCX, plain read for.txt/.md/.csv/.json/.log. A scanned, image-only PDF extracts nothing, and the node says so explicitly (that's the OCR path's job, not this one's). - Builds a text-document record:
document_name(defaults to the file stem), stored underfield_root(defaultdocument_text) withraw_text,text_length,line_count, and asource_fileblock with path, filename, extension, content type, size, and ingest timestamp. - Saves into
collection_name(defaulttext_documents) - re-running withoverwrite(defaulttrue) updates the same-named record instead of duplicating it, andmetadata_json/tags_jsonride along for your own organization.
Outputs worth grabbing: document_id and document_id_link (feed into Get Text / Get Value later), text (the extracted text, right there if you want to use it immediately), text_length, local_limit_bytes (see below), filename_link, success, and the document_ids / text_items list tails.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/CentralFloridaAttorney/ComfyUI-ZMongo
pip install pymupdf python-docx
Restart ComfyUI (or install "ComfyUI-ZMongo" via Manager). pymupdf and python-docx are the two real dependencies here - without them, extraction fails.
Where people get burned
The big one is the local size cap. In Local File Store mode this node deliberately does not chunk documents, and there's a hard ceiling of 256 KB of extracted text (the local_limit_bytes output shows it). Hit it and the ingest refuses, with a payload telling you to use the hosted ZMongo backend (BusinessProcessApplications.com), where the server-side ZEmbedder.py does chunking and embeddings. Short documents are fine locally; long ones need the hosted path.
Second: scanned PDFs. If extraction returns empty, it's almost always an image-only PDF. The node's error message is explicit - "this may be a scanned PDF; use OCR ingestion instead." That means "06 Queue Document OCR" on the hosted backend, not this node.
And third, the collection default is text_documents, not documents. Remember that when you later fetch this text with "06 Get Document Text," which defaults to documents - set its collection_name to match or the fallback will miss your record.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| session | ZMONGO_API_SESSION | — | |
| file_path | STRING | — | |
| document_name | STRING | — | |
| collection_name | STRING | text_documents | — |
| field_root | STRING | document_text | — |
| overwrite | BOOLEAN | true | — |
| metadata_json | STRING | {} | — |
| tags_json | STRING | [] | — |
| file_path_linkopt | * | — | |
| refresh_tokenopt | STRING | — |
Outputs (15)
| Name | Type | Description |
|---|---|---|
| json | STRING | — |
| document_id | STRING | — |
| document_id_link | ZMONGO_DOCUMENT_ID | — |
| document_name | STRING | — |
| filename_link | ZMONGO_FILENAME | — |
| text | STRING | — |
| text_length | INT | — |
| local_limit_bytes | INT | — |
| success | BOOLEAN | — |
| refresh | STRING | — |
| document_ids | * | — |
| text_items | * | — |
| selectable_items | * | — |
| indexed_items | STRING | — |
| item_count | INT | — |