---
Product: Aspose.PDF
Platform: java
Page Type: docs
Canonical URL: https://docs.aspose.org/pdf/java/developer-guide/text
---

# Text

Text handling and FormattedText in Aspose.PDF FOSS for Java.

## Text API

Aspose.PDF FOSS for Java provides text handling through multiple APIs depending
on the use case.

## FormattedText

`FormattedText` represents styled text for use in stamps and annotations. It
encapsulates the text string along with font, size, and color properties.

## Text Replacement

`PdfContentEditor.replaceText()` substitutes text strings within PDF content streams:

```java
try (PdfContentEditor editor = new PdfContentEditor()) {
    editor.bindPdf("input.pdf");
    editor.replaceText("old text", "new text");
    editor.save("output.pdf");
}
```

`TextReplaceOptions` provides additional control over how text matching and
replacement is performed.

## Text Extraction

`PdfExtractor` provides a page-by-page text extraction API. After calling
`extractText()`, iterate with `hasNextPageText()` / `getNextPageText()`.

See the [Facades](../facades) page for a complete `PdfExtractor` example.

## See Also

- [Aspose.PDF for Java — Enterprise Documentation](https://docs.aspose.com/pdf/java/)