Text

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:

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 page for a complete PdfExtractor example.

See Also