# What File Formats Can RAGAnything Process? A Complete Guide to PDF, Office, Images, and Text Handling

> Explore supported file formats like PDF, Office docs, images, and text in RAGAnything. Learn how its intelligent pipelines convert content for effective RAG.

- Repository: [✨Data Intelligence Lab@HKU✨/RAG-Anything](https://github.com/HKUDS/RAG-Anything)
- Tags: how-to-guide
- Published: 2026-04-22

---

**RAGAnything supports 20+ file formats including PDF, images (JPG, PNG, GIF, WebP), Microsoft Office documents (DOCX, PPTX, XLSX), HTML, and plain-text/Markdown files, with intelligent conversion pipelines that normalize all content to structured PDF for parsing.**

RAGAnything is an open-source document processing framework designed for retrieval-augmented generation (RAG) pipelines. Understanding what file formats RAGAnything can process—and how it handles each type—is essential for building robust document ingestion workflows. This guide breaks down the supported formats, processing pipelines, and fallback mechanisms implemented in the HKUDS/RAG-Anything codebase.

## Supported File Formats in RAGAnything

RAGAnything defines its supported extensions centrally in `RAGAnythingConfig.supported_file_extensions` ([source](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/config.py#L61-L68)):

| Category | Extensions |
|----------|-----------|
| PDF | `.pdf` |
| Images | `.jpg`, `.jpeg`, `.png`, `.bmp`, `.tiff`, `.tif`, `.gif`, `.webp` |
| Office & HTML | `.doc`, `.docx`, `.ppt`, `.pptx`, `.xls`, `.xlsx`, `.html`, `.htm`, `.xhtml` |
| Plain-text & Markdown | `.txt`, `.md` |

When `RagAnythingProcessor.process_file` receives a file, it inspects the suffix and routes to the appropriate handler ([processor logic](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/processor.py#L64-L84)).

## How RAGAnything Processes PDF Files

PDFs are the native format for RAGAnything's parsing pipeline. The processor passes them directly to the configured parser without conversion.

```python
content_list = await asyncio.to_thread(
    doc_parser.parse_pdf,
    pdf_path=file_path,
    output_dir=output_dir,
    method=parse_method,
    **kwargs,
)

```

([processor snippet](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/processor.py#L64-L73))

The **parser** (e.g., MinerU, Docling, or PaddleOCR) extracts **page-wise content blocks**—preserving structural information like headers, paragraphs, tables, and figures. This block-level output is ideal for chunking strategies in RAG pipelines.

## How RAGAnything Processes Image Files

Images follow a **two-tier parsing strategy** with automatic fallback:

```python
try:
    content_list = await asyncio.to_thread(
        doc_parser.parse_image,
        image_path=file_path,
        output_dir=output_dir,
        **kwargs,
    )
except NotImplementedError:
    # fallback to MinerU

    content_list = await asyncio.to_thread(
        MinerUParser().parse_image,
        image_path=file_path,
        output_dir=output_dir,
        **kwargs,
    )

```

([processor snippet](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/processor.py#L84-L99))

**Step 1:** The processor attempts to use the **primary parser's** `parse_image` method.

**Step 2:** If the parser raises `NotImplementedError` (image parsing not supported), RAGAnything **automatically falls back to MinerUParser**. This ensures OCR capabilities without manual configuration.

Supported image formats leverage this pipeline: **JPG, JPEG, PNG, BMP, TIFF, TIF, GIF, and WebP**.

## How RAGAnything Processes Office Documents and HTML Files

Microsoft Office files (DOC, DOCX, PPT, PPTX, XLS, XLSX) and HTML variants require **conversion to PDF** before parsing:

```python
pdf_path = cls.convert_office_to_pdf(doc_path, output_dir)

```

The `convert_office_to_pdf` method ([source](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/parser.py#L100-L128)):

1. **Launches LibreOffice headlessly** (`libreoffice` or `soffice` command)
2. **Watches the temporary output folder** for the generated PDF
3. **Validates the PDF** was created successfully
4. **Copies to the final location** and returns the path

The resulting PDF is then processed through the standard **PDF parsing pipeline**, preserving the original document's structure.

## How RAGAnything Processes Plain-Text and Markdown Files

TXT and MD files follow a similar **conversion-to-PDF** pattern with specialized rendering:

```python
pdf_path = cls.convert_text_to_pdf(text_path, output_dir)

```

The `convert_text_to_pdf` method ([source](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/parser.py#L254-L277)):

1. **Reads the source file** and validates the suffix (`.txt` or `.md`)
2. **Renders to PDF using ReportLab** with full **Markdown support**
3. **Returns the PDF path** for standard parsing

This approach ensures **consistent block-level output** across all file types, regardless of original format.

## Complete Code Example: Processing Multiple File Formats

```python
from raganything.raganything import RagAnything

# Initialize with default config (environment variables can override defaults)

rag = RagAnything()

# 1. Parse a PDF

pdf_content, pdf_id = await rag.process_file("sample.pdf")
print(f"PDF parsed → {len(pdf_content)} blocks (doc_id={pdf_id})")

# 2. Parse an image (falls back to MinerU if needed)

img_content, img_id = await rag.process_file("photo.png")
print(f"Image parsed → {len(img_content)} blocks (doc_id={img_id})")

# 3. Parse an Office document (auto-converted to PDF first)

doc_content, doc_id = await rag.process_file("presentation.pptx")
print(f"Office doc parsed → {len(doc_content)} blocks (doc_id={doc_id})")

# 4. Parse a markdown file

md_content, md_id = await rag.process_file("readme.md")
print(f"Markdown parsed → {len(md_content)} blocks (doc_id={md_id})")

```

## Key Implementation Files

| File | Role |
|------|------|
| [`raganything/config.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/config.py) | Holds the master list of supported extensions and default config values |
| [`raganything/processor.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/processor.py) | Dispatches files to the appropriate parser based on suffix; implements fallback logic |
| [`raganything/parser.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/parser.py) | Implements the conversion utilities (`convert_office_to_pdf`, `convert_text_to_pdf`) and abstract parser interface |
| [`raganything/base.py`](https://github.com/HKUDS/RAG-Anything/blob/main/raganything/base.py) / parsers (e.g., `minerU` implementation) | Concrete parsing implementations for PDF, image, and generic documents |

## Summary

- **RAGAnything supports 20+ file formats** across PDF, images, Office documents, HTML, and plain-text/Markdown files
- **PDFs are processed natively** by the configured parser (MinerU, Docling, PaddleOCR) with page-wise block extraction
- **Images use intelligent fallback**: primary parser first, then automatic MinerU fallback if `NotImplementedError` occurs
- **Office and HTML files convert to PDF via LibreOffice** before parsing, ensuring structural preservation
- **Text and Markdown render to PDF via ReportLab** with full Markdown support, then follow standard PDF parsing

## Frequently Asked Questions

### Can RAGAnything process scanned PDFs?

Yes. RAGAnything delegates PDF parsing to configurable backends like MinerU, Docling, or PaddleOCR—all of which include OCR capabilities for scanned documents. The specific OCR quality depends on which parser you configure.

### What happens if my image format isn't supported by the primary parser?

RAGAnything automatically falls back to MinerUParser. The processor catches `NotImplementedError` from the primary parser's `parse_image` method and retries with MinerU, ensuring OCR capabilities without manual intervention.

### Does RAGAnything require LibreOffice to be installed?

Yes, for Office document processing (DOC, DOCX, PPT, PPTX, XLS, XLSX). The `convert_office_to_pdf` method in [`parser.py`](https://github.com/HKUDS/RAG-Anything/blob/main/parser.py) invokes `libreoffice` or `soffice` headlessly. Without LibreOffice, these file types will fail to process.

### Is Markdown formatting preserved when parsing .md files?

Partially. Markdown files are converted to PDF using ReportLab with "full markdown support" according to the source. The resulting PDF preserves structural elements (headers, lists, emphasis), which are then extracted as content blocks. However, complex Markdown features may render differently than in a dedicated Markdown viewer.