> For the complete documentation index, see [llms.txt](https://docs.umbraco.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbraco.com/umbraco-cms/19.latest/develop-with-umbraco/search/searching-file-content/adding-file-formats.md).

# Adding file formats

Developer documentation for extending the file-to-text indexing package.

The file-to-text indexing package is extendable, so you can add support for additional file formats. This is done by implementing an `IFileValueHandler` for each file format.

## Example

The following example adds MS Word (`.docx`) as a supported file format. It leverages [`DocSharp.Docx`](https://www.nuget.org/packages/DocSharp.Docx) to parse Word files into plain text.

{% code title="DocxFileValueHandler.cs" %}

```csharp
using DocSharp.Docx;
using Umbraco.Cms.Search.Extension.FileToText.FileIndexing;

namespace My.Site.FileValueHandlers;

public class DocxFileValueHandler : IFileValueHandler
{
    public bool CanHandle(string extension)
        => extension.InvariantEquals(".docx");

    public Task<string> GetFileContentsAsync(Stream stream, CancellationToken cancellationToken)
    {
        var converter = new DocxToTxtConverter();
        var text = converter.ConvertToString(stream);
        return Task.FromResult(text);
    }
}
```

{% endcode %}

The `IFileValueHandler` implementation must be registered as singleton:

{% code title="DocxFileValueHandler.cs" %}

```csharp
using My.Site.FileValueHandlers;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Search.Extension.FileToText.FileIndexing;

namespace My.Site.DependencyInjection;

public class DocxFileValueHandlerComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder)
        => builder.Services.AddSingleton<IFileValueHandler, DocxFileValueHandler>();
}
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbraco.com/umbraco-cms/19.latest/develop-with-umbraco/search/searching-file-content/adding-file-formats.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
