Text

文本API

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

FormattedText

FormattedText 代表在邮票和注释中使用的风格文本. 封装文字串,以及字体,大小和颜色属性.

文本替换

PdfContentEditor.replaceText() 在PDF内容流中替换文字串:

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

TextReplaceOptions 提供了对文本匹配和 进行更换.

文本提取

PdfExtractor 提供一个页面逐页文本提取API. extractText(), 代与 hasNextPageText() / getNextPageText().

见第3条. Facades 页面的完整版. PdfExtractor 举一个例子.

See Also

 中文