# Extracting Text from PDF Documents

## Environment

| Version | Product          | Author                                                                          |
| ------- | ---------------- | ------------------------------------------------------------------------------- |
| Q1 2025 | RadPdfProcessing | [Desislava Yordanova](https://www.telerik.com/blogs/author/desislava-yordanova) |

## Description

Learn how to extract the text content from a PDF document.

## Solution

Follow these steps:

1. Import the PDF document with the [`PdfFormatProvider`](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/pdf/pdfformatprovider/pdfformatprovider).

2. Export the `RadFixedDocument` content to text with the [`TextFormatProvider`](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/plain-text/textformatprovider). If the PDF document contains text fragments, the provider exports them to a plain text result.

```csharp
            string filePath = "input.pdf";
            PdfFormatProvider pdf_provider = new PdfFormatProvider();
            RadFixedDocument fixed_document;
            using (Stream stream = File.OpenRead(filePath))
            {
                fixed_document = pdf_provider.Import(stream);
            }
            Telerik.Windows.Documents.Fixed.FormatProviders.Text.TextFormatProvider provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Text.TextFormatProvider();

            string documentContent = provider.Export(fixed_document);
            Debug.WriteLine(documentContent);
```

> important The `TextFormatProvider` may not cover all scenarios depending on the internal document content. A common case is a document with scanned images that contain text information. In this case, the above approach does not parse the content to plain text because the text is represented as [`Path`](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/model/path) elements. Use the [`OcrFormatProvider`](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/ocrformatprovider) to convert images of typed, handwritten, or printed text into machine-encoded text from a scanned document.

## See Also

* [RadPdfProcessing](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/overview)
* [OcrFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/ocr/ocrformatprovider)
* [TextFormatProvider](https://www.telerik.com/document-processing-libraries/documentation/libraries/radpdfprocessing/formats-and-conversion/plain-text/textformatprovider)
* [Summarizing the Text Content of PDF Documents using Text Analytics with Azure AI services](https://www.telerik.com/document-processing-libraries/documentation/knowledge-base/summarize-pdf-content)
