Automate Document Workflows with Nextcloud, Paperless-NGX & AI

The large context sizes reaching 1 million tokens (2,500 to 3,000 pages), and powerful vision capabilities of the newest, state-of-the-art large language models (LLMs) such as Google Gemini 2.5 Flash and Llama 4 Maverick make them increasingly relevant for automated tagging and text extraction (OCR) from document scans and non-text searchable PDF files. If you are looking for a self-hosted, open source document management stack, we can recommend using Nextcloud, Paperless-NGX, and companions such as Paperless-GPT and Paperless-AI which leverage the Paperless-NGX API. 

Later in this article, we will discuss the main differences in functionality between Paperless-GPT and Paperless-AI, which can both be plugged into serverless (cloud based) or on prem AIs. If your business is drowning in digitized documents and you want to save time organizing and making them searchable in your own private cloud automatically, then our document management solution might be for you. 

Document management systems and solutions (DMS) can enhance productivity for virtually any business, but particularly enterprises which handle a large volume of scanned or digitized paper documents in their day-to-day operations. This is particularly true if keeping such records for an extended period of time is required for legal or compliance requirements, for example, mailrooms of law offices, accounting firms, fintechs, or corporate service providers. For other professional & technical services such as engineering and architectural firms, implementing a DMS provides the invaluable capability to call up a document from any active or archived project with full-text search at one’s fingertips.  

Traditional document management systems, such as those by OpenText or Mayan EDMS, can require a considerable amount of time to implement and train users, in addition to demanding complex hardware & software requirements, and enterprise licensing and support costs starting from $29K-35K/year, increasing based on the number of users and processed documents. Our stack is user-friendly enough for even an individual user or small team to easily get started with, and can run on virtually any cloud platform. Furthermore, it integrates with the current AI models, and is easily upgradable to future models supporting an Ollama or OpenAI-compatible endpoint – without requiring any additional licensing costs. There is also no per-user or per-document pricing, allowing you to scale based on only the limits of the hardware.

Open Source, Self-Hosted Document Management System (DMS) Stack Components

Our self-hostable stack for automating document workflows consists of three (or four) main components, depending on whether your requirements call for using Paperless-AI, Paperless-GPT, or both:

  • Nextcloud – cloud storage (similar to Sharepoint or Google Drive) accessible through a web browser or from desktop & mobile devices over the WebDAV protocol
  • Paperless-NGX – document management system (DMS) for tagging, viewing, and searching uploaded scans and PDFs. Automatically OCRs files using the OCRmyPDF library and Tessaract, a traditional machine learning (ML) model. Supports multiple users and sharing permissions (owner, view, and edit permissions).Paperless-NGX user interface screenshot
  • Paperless-AI integrates Paperless-NGX with Azure OpenAI, Google Gemini, or Ollama (Mistral, Llama, Phi-4, Gemma 3) models for document analysis, automated tagging, and RAG chat
    • Applies tags based on the AI model’s understanding of document contents using existing tags only, or with suggested new tags (this is a customizable setting). Also auto-populates the Title, Date Created, Correspondent, and Document Type fields, as well as any custom fields as instructed in your prompt.
      • It automatically splits up your documents based on the max context size of the chosen model and provider, and sends them to the inference server in multiple chunks – to prevent “context length exceeded” errors.
    • It indexes your documents into a built-in RAG database in the background so that you can ask questions about it using natural language prompts, similar to ChatGPT. The chatbot cites up to five (5) documents at a time, as sources for its answers.Paperless-AI admin dashboard screenshot
  • Paperless-GPT – integrates Paperless-NGX with vision-capable models such as gpt-4o-mini (64K context length) or Gemini 2.5 Flash (1M context length) to extract text from uploaded documents using LLM-powered OCR, even if uploaded as a scanned image, and not a text-searchable PDF. 
    • Can optionally use enterprise-grade solutions such as Azure Document Intelligence or Google Document AI, as an alternative to LLM-based OCR.
    • Google Document AI is able to generate the hOCR text layer and combine it with the original PDF document, making text in PDF documents highlightable and searchable (document be uploaded originally in PDF format). This results in higher OCR accuracy than with Paperless-NGX’s default Tessaract model).
    • Also auto-titles and tags documents like Paperless-AI, using a cloud-based LLM such as Gemini 2.5 Flash, or a local LLM such as Qwen3-8B running on a GPU instance or your own hardware. The tagging functionality in Paperless-GPT can be enabled or disabled, based on whether Paperless-AI (or any other solution) is being used for automated tagging instead. Paperless-GPT screenshot

In order for documents to be transferred smoothly and automatically from Nextcloud to Paperless-NGX and the chosen AIs, setting up the proper external storages in Nextcloud, storage paths and workflows in Paperless-NGX, and document tags which trigger tag generation and/or OCR in Paperless-AI and Paperless-GPT is required. 

Example Document Workflows with Nextcloud and Paperless-NGX

A typical document pipeline for automating the ingestion of documents to Paperless-NGX would look something like this: 

  1. Documents are uploaded to a “consumption” folder in a user’s Nextcloud share. This folder must be accessible by both Nextcloud and Paperless-NGX, usually on the same server, but could also be a shared volume such as a NFS instead in a distributed setup.
  2. The documents are swept into a per-user “uploads” path of Paperless-NGX. This directory is accessible to both Nextcloud and Paperless-NGX, allowing the original document to be viewable in both applications. The document is converted into a PDF if it is in a different format, then processed with traditional OCR and/or AI-powered OCR through Paperless-GPT.
  3. Additionally, the content of the document is processed through an LLM in either Paperless-AI or Paperless-GPT with a prompt instructing the chosen AI model to serve as a “personalized document analyzer.” Title, Date Created, Correspondent, Document Type, Tags, and any custom fields (if applicable) are automatically applied to the document in Paperless-NGX through the API.
  4. If using Paperless-AI’s RAG chat feature, documents are indexed into a vector database at a set interval in the background. The ChatGPT-style chatbot grounds its responses to user prompts on the overall body of knowledge of the uploaded documents. 

Automated Tagging, Categorization, and AI-Powered OCR

It might be desirable to only process a sub-set of the documents uploaded to Nextcloud and Paperless-NGX through AI-powered document analysis and OCR. In this case, Paperless-AI and Paperless-GPT can be configured to process only documents with certain tags (e.g. “paperless-gpt-auto” and “paperless-gpt-ocr-auto”) through the configured LLM (local or cloud) or enterprise-grade OCR/HTR solution. 

For example, because Paperless-GPT’s implementation of Google Document AI is only able to generate the hOCR layer for files which were originally uploaded as a PDF to Paperless-NGX (not image files converted to a PDF by Paperless-NGX), we can create a custom workflow where only files with a *.pdf extension are tagged with “paperless-gpt-ocr-auto” and processed through Document AI.

The use of custom tags to trigger document analysis through a LLM or AI-powered OCR also provides the flexibility to create workflows which automatically process documents uploaded by specified Nextcloud users, but not other Nextcloud users based on business requirements. This might be needed for withholding certain documents which should not be processed through any AI solution for privacy reasons, but still need to be archived in Paperless-NGX. 

It’s also possible to set up multiple consumption folders for the same Nextcloud user which lead to different Paperless-NGX workflows with different behaviors, such as categorization, tagging rules, and access permissions. For instance, this might be helpful if documents scanned into different folders on a user’s workstation should be classified as different Document Types in Paperless-NGX. 

Businesses that rely on a mobile workforce can instruct their field service contractors or sales representatives to use a document scanning app (e.g. Microsoft Lens or Adobe Scan) to capture paperwork such as expense or sales receipts and mileage reports. As soon as those scans are uploaded through the Nextcloud app to the users’ consumption folder, those files will automatically flow through to Paperless-NGX for processing – ensuring more accurate and complete record-keeping.

In addition to properly architecting your cloud environment with the appropriate compute, storage, and AI resources, and installing the software components according to best practices, our cloud, AI & data consultants also assist organizations with setting up the document pipelines and configuring the applications for your administrators and users.

AI-Powered OCR, Document AI, Document Management Systems, Document Workflows, Gemini AI, GPT Document Analysis, NextCloud, Paperless-NGX, Retrieval Augmented Generation
Previous Post
Technical Deep Dive Into Nextcloud Context Chat

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.