Install this extension via the ComfyUI Manager by searching
for ComfyUI-Documents
1. Click the Manager button in the main menu
2. Select Custom Nodes Manager button
3. Enter ComfyUI-Documents in the search bar
After installation, click the Restart button to
restart ComfyUI. Then, manually
refresh your browser to clear the cache and access
the updated list of nodes.
Visit
ComfyUI Online
for ready-to-use ComfyUI environment
ComfyUI-Documents is an extension for ComfyUI that enhances workflows by enabling advanced document processing. It supports loading, parsing, and converting various document types (PDF, TXT, DOC, DOCX), extracting text, and converting PDF pages to images, integrating seamlessly with ComfyUI projects.
ComfyUI-Documents Introduction
ComfyUI-Documents is a powerful extension for the ComfyUI application, designed to enhance your workflow with advanced document processing capabilities. This extension seamlessly integrates document handling, parsing, and conversion features directly into your ComfyUI projects. Whether you are working with PDFs, text files, or Microsoft Word documents, ComfyUI-Documents provides the tools you need to efficiently manage and process your documents. This extension is particularly useful for AI artists who need to extract and manipulate text and images from various document formats, making it easier to incorporate these elements into their creative projects.
How ComfyUI-Documents Works
ComfyUI-Documents works by adding custom nodes to your ComfyUI workflow, each designed to handle specific document processing tasks. Think of these nodes as building blocks that you can connect together to create a customized document processing pipeline. For example, you can use one node to load a document, another to convert PDF pages to images, and yet another to split text into manageable chunks. By connecting these nodes in different ways, you can create a workflow that meets your specific needs.
Imagine you have a PDF document with multiple pages, and you want to extract images from specific pages and then process those images further. You can use the "PDF to Image" node to convert the pages to images, the "PDF Page Splitter" node to select the pages you are interested in, and the "Image Selector" node to pick the specific images you want to work with. This modular approach makes it easy to customize your workflow and achieve the desired results.
ComfyUI-Documents Features
Document Loader Node
Description: Easily browse, select, and parse documents from your input directory.
Supported Formats: PDF, TXT, DOC, DOCX.
Capabilities: Extracts text content, images, and metadata from documents.
Usage:
Add the "Document Loader" node to your ComfyUI workflow.
Use the dropdown to select a document from your input directory, or use the "Choose file to upload" button to add a new document.
Connect the output to other nodes in your workflow to process the extracted text, images, or metadata.
Document Loader Node
PDF to Image Node
Description: Convert PDF pages into high-quality image tensors.
Features:
Flexible page range selection for partial document processing.
Adjustable DPI settings for output image quality control.
Usage:
Add the "PDF to Image" node to your ComfyUI workflow.
Select a PDF file using the dropdown or file upload button.
Set the desired page range and DPI.
The node will output image tensors that can be used with other ComfyUI image processing nodes.
PDF to Image Node
PDF Page Splitter Node
Description: Select specific pages from a PDF document.
Features:
Choose individual pages or ranges of pages.
Output selected pages as separate image tensors.
Usage:
Add the "PDF Page Splitter" node to your workflow.
Select a PDF file using the dropdown.
Enter the desired page numbers (e.g., "1,3,5" or "1-5,7,9-11").
Set the DPI for the output images.
The node will output the selected pages as separate image tensors.
PDF Page Splitter Node
Image Selector Node
Description: Pick specific images from a batch of images.
Features:
Select one or multiple images by index.
Useful for further processing of specific pages from PDF conversions.
Usage:
Connect the output of a PDF to Image or PDF Page Splitter node to the Image Selector node.
Enter the indexes of the images you want to select (e.g., "0" for the first image, or "0,2,4" for the first, third, and fifth images).
The node will output only the selected images for further processing.
Text Chunker Node
Description: Divide large text into manageable chunks.
Features:
Split text by character or word count.
Respect word boundaries for more natural text division.
Usage:
Connect the output of a Document Loader or any text-producing node to the Text Chunker node.
Set the desired chunk size and method (characters or words).
Choose whether to respect word boundaries.
The node will output chunked text and corresponding indices.
Text Chunker Node
Chunk Router Node (Currently Not Working) (WIP)
Description: Select specific text chunks for further processing.
Features:
Route individual chunks to different parts of your workflow.
Useful for processing long documents in parts.
Usage:
Connect the output of the Text Chunker node to the Chunk Router node.
Select the index of the chunk you want to process.
The node will output the selected chunk for further processing.
Troubleshooting ComfyUI-Documents
Common Issues and Solutions
Node Not Appearing in Workflow:
Solution: Ensure that the extension is properly installed and that you have restarted ComfyUI after installation. Check the custom nodes directory to confirm that the ComfyUI-Documents folder is present.
Document Not Loading:
Solution: Verify that the document format is supported (PDF, TXT, DOC, DOCX). Ensure that the file path is correct and that the file is not corrupted.
PDF to Image Conversion Issues:
Solution: Check the page range and DPI settings. Ensure that the PDF file is not password-protected or encrypted.
Text Chunker Not Splitting Text Correctly:
Solution: Adjust the chunk size and method settings. Ensure that the "Respect word boundaries" option is enabled if you want more natural text division.
Frequently Asked Questions (FAQs)
Q: Can I use ComfyUI-Documents with other ComfyUI nodes?
A: Yes, ComfyUI-Documents nodes are designed to integrate seamlessly with other ComfyUI nodes, allowing you to create complex workflows.
Q: What file formats are supported by ComfyUI-Documents?
A: ComfyUI-Documents supports PDF, TXT, DOC, and DOCX file formats.
Q: How can I contribute to the development of ComfyUI-Documents?
For more information and updates, please visit the ComfyUI-Documents GitHub repository. You can also explore the following resources to learn more about the libraries used in this extension:
PyMuPDF: A library for robust PDF processing capabilities.
python-docx: A library for handling Microsoft Word documents.
These resources provide additional documentation, tutorials, and community support to help you get the most out of ComfyUI-Documents.