Extract Text From Stamps
Contents
[
Hide
]
Extract Text from Stamp Annotations
Aspose.PDF for Java lets you extract text from stamp annotations. In order to extract text from Stamp Annotations in a PDF, the following steps can be used.
- Create a Document class object
- Get the desired Annotation from list of annotations of a page
- Define a new object of TextAbsorber class
- Use the TextAbsorber’s visit method to get the Text
Document doc = new Document(dataDir+"test.pdf");
Annotation item = doc.getPages().get_Item(1).getAnnotations().get_Item(3);
if (item instanceof StampAnnotation ) {
StampAnnotation annot = (StampAnnotation) item;
TextAbsorber ta = new TextAbsorber();
XForm ap = annot.getNormalAppearance();
ta.visit(ap);
System.out.println(ta.getText());
}