Код: Выделить всё
try (PDDocument document = Loader.loadPDF(file)) {
final PDFTextStripper pdfStripper = new PDFTextStripper();
pdfStripper.setSortByPosition(true);
text = pdfStripper.getText(document);
}
Код: Выделить всё
for (final PDAnnotation annotation : page.getAnnotations()) {
// custom print process which recursively dumps the fields and displays classes and values
}
< /code>
Тримирован только к специфике аннотации: < /p>
Annotation (class PDAnnotationWidget)
Name: null
COSObject:
AP:
...
Rect:
Item #0 (COSFloat)
Value: 13.3036
Item #1 (COSFloat)
Value: 717.61
Item #2 (COSFloat)
Value: 285.541
Item #3 (COSFloat)
Value: 729.163
StructParent:
Value: 0
Subtype:
Name: Widget
T:
Text: name_01_1
TU:
Text: Name (Last, First, Middle)
Type:
Name: Annot
V:
Text: {My Name in Last, First, Middle}
Appearance:
Operator
Name: SAVE
Operator
Name: RESTORE
Operator
Name: BEGIN_MARKED_CONTENT
Argument #1 (COSName)
Name: Tx
Operator
Name: SAVE
Operator
Name: ENDPATH
Operator
Name: SAVE
Operator
Name: BEGIN_TEXT
Operator
Name: SET_FONT_AND_SIZE
Argument #1 (COSName)
Name: F1
Argument #2 (COSInteger)
Value: 8
Operator
Name: MOVE_TEXT
Argument #1 (COSInteger)
Value: 2
Argument #2 (COSFloat)
Value: 3.54
Operator
Name: SHOW_TEXT
Argument #1 (COSString)
Text: {My Name in Last, First, Middle}
Operator
Name: END_TEXT
Operator
Name: RESTORE
Operator
Name: RESTORE
Operator
Name: END_MARKED_CONTENT
Подробнее здесь: https://stackoverflow.com/questions/793 ... xtstripper
Мобильная версия