Nodes/ComfyUI-ZMongo/06 Ingest Text PDF / DOCX
ComfyUI Node

06 Ingest Text PDF / DOCX

Turn a PDF or DOCX into a searchable database record

By CentralFloridaAttorney·Created 5 months ago·Updated 2 months ago· 1
06 Ingest Text PDF / DOCX
  • 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
file_path
document_name
collection_nametext_documents
field_rootdocument_text
overwritetrue
metadata_json{}
tags_json[]
refresh_token

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:

  1. Extracts text locally - pymupdf for PDFs, python-docx for 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).
  2. Builds a text-document record: document_name (defaults to the file stem), stored under field_root (default document_text) with raw_text, text_length, line_count, and a source_file block with path, filename, extension, content type, size, and ingest timestamp.
  3. Saves into collection_name (default text_documents) - re-running with overwrite (default true) updates the same-named record instead of duplicating it, and metadata_json / tags_json ride 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.

CategoryZMongo/03 Documents

Inputs (10)

NameTypeDefaultDescription
sessionZMONGO_API_SESSION
file_pathSTRING
document_nameSTRING
collection_nameSTRINGtext_documents
field_rootSTRINGdocument_text
overwriteBOOLEANtrue
metadata_jsonSTRING{}
tags_jsonSTRING[]
file_path_linkopt*
refresh_tokenoptSTRING

Outputs (15)

NameTypeDescription
jsonSTRING
document_idSTRING
document_id_linkZMONGO_DOCUMENT_ID
document_nameSTRING
filename_linkZMONGO_FILENAME
textSTRING
text_lengthINT
local_limit_bytesINT
successBOOLEAN
refreshSTRING
document_ids*
text_items*
selectable_items*
indexed_itemsSTRING
item_countINT