# PDF support in Discourse AI (RAG)

**URL:** https://meta.discourse.org/t/pdf-support-in-discourse-ai-rag/352829
**Category:** Site Management
**Tags:** how-to, ai
**Created:** [February 18, 2025, 4:32am UTC](https://meta.discourse.org/t/pdf-support-in-discourse-ai-rag/352829 "2025-02-18T04:32:26Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [February 18, 2025, 4:32am UTC](https://meta.discourse.org/t/pdf-support-in-discourse-ai-rag/352829/1 "2025-02-18T04:32:27Z")

</div>

> 🔖 This guide explains how to implement and use PDF processing capabilities within discourse-ai, including both basic text extraction and enhanced processing with LLM assistance.
> 
> 🙋 Required user level: Administrator

## Summary

The discourse-ai plugin supports PDF processing for RAG (Retrieval-Augmented Generation) in two distinct modes:

1. Basic text extraction
2. Enhanced processing with LLM analysis

## Basic text extraction

This mode provides fundamental PDF processing capabilities:

- Extracts text content using the `pdf-reader` gem
- Supports files up to 100MB
- Works immediately after plugin installation
- Processes text-only content (ignores visual elements)

## Enhanced processing with LLM improvements

ℹ This mode requires specific configuration and provides more advanced capabilities.

Requirements:

- Enterprise plan subscription or self-hosted Discourse
- ImageMagick with Ghostscript support installed in container
- `ai_rag_images_enabled` site setting enabled (hidden — must be set via Rails console)
- A RAG LLM model configured on the AI agent or tool

Capabilities:

- Interprets images, charts, and diagrams
- Provides context from visual elements
- Processes PDFs page by page
- Maintains the 100MB file size limit
- Enables image file uploads (png, jpg, jpeg) for RAG indexing via LLM-based text extraction

## Implementation details

### Processing specifications

- Page processing resolution: 300 DPI
- Per-page image conversion timeout: 30 seconds
- Automatic cleanup of temporary files
- Full integration with RAG document embeddings

### Processing workflow

1. PDF upload and validation
2. Content extraction (basic or enhanced mode)
3. Text chunking with configurable overlap
4. Chunk embedding and storage
5. Progress tracking via MessageBus

## Limitations

⚠ Be aware of these constraints when implementing PDF processing:

- File size restrictions:
  - 100MB for existing PDF processing
  - 20MB for new admin interface uploads

- Enhanced mode requires additional system resources
- Complex PDF layouts may not be perfectly interpreted
- Enhanced processing increases processing time significantly

### See also:

> [@Using PDF and attachment support with AI bots](https://meta.discourse.org/t/using-pdf-and-attachment-support-with-ai-bots/391005):
>
> bookmark This guide explains how to enable and use native PDF and document attachment support when interacting with AI bots in Discourse. Users can upload PDFs and other documents directly in conversations with AI agents. person_raising_hand Required user level: Administrator Summary Discourse AI now supports native attachment handling, allowing users to upload PDFs and other document types directly when conversing with AI bots. The AI can read and understand the content of these attachm…

---

_[View the full topic](https://meta.discourse.org/t/pdf-support-in-discourse-ai-rag/352829)._
