> ## Documentation index
> Fetch the complete documentation index at: https://oxidizepdf-net.docs7.io/llms.txt
> Ask it with GET https://oxidizepdf-net.docs7.io/ask?q=<keywords or question>. Short keywords rank best.
> Use these to discover all available pages before exploring further.

# Install and extract PDF text

> Read text and structured chunks with OxidizePdf.NET 0.20.2.

Create a .NET 8 or newer console project and add the package:

```bash
dotnet new console -n PdfExample
cd PdfExample
dotnet add package OxidizePdf.NET --version 0.20.2
```

Place a text-bearing PDF named `document.pdf` in the project directory. Replace `Program.cs` with:

```csharp
using OxidizePdf.NET;
using OxidizePdf.NET.Pipeline;

byte[] pdfBytes = File.ReadAllBytes("document.pdf");
var extractor = new PdfExtractor();

string text = await extractor.ExtractTextAsync(pdfBytes);
Console.WriteLine(text);

var chunks = await extractor.RagChunksAsync(pdfBytes, ExtractionProfile.Rag);
foreach (var chunk in chunks)
{
    Console.WriteLine($"Pages: {string.Join(", ", chunk.PageNumbers)}");
    Console.WriteLine(chunk.FullText);
}
```

Run `dotnet run`. The output contains extracted text and chunks with their source pages. `PageNumbers` uses one-based page numbers. `FullText` includes heading context when available.

`PdfExtractor` is not disposable in this package version. File and PDF errors propagate to the caller in this minimal example. For a service, handle errors at the request boundary and apply input limits appropriate to the workload.

This example reads the entire file into memory and performs both extraction operations. It is not a streaming example. Text extraction needs a text layer; scanned pages need OCR.
