Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.pdf

public final Class TextExtractor

extends Object
Class Inheritance
Annotations
@AllowedToUseAwt:org.apache.pdfbox.text.PDFTextStripperByArea.addRegion uses AWT\'s Rectangle to indicate a region
Imports
java.awt.geom.Rectangle2D, java.io.IOException, org.jabref.architecture.AllowedToUseAwt, org.apache.pdfbox.cos.COSArray, .COSFloat, .COSInteger, org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.text.PDFTextStripperByArea, org.jspecify.annotations.NonNull

Extracts the text of marked annotations using bounding boxes.

Field Summary

Modifier and TypeField and Description
private final COSArray
private final PDPage

Constructor Summary

AccessConstructor and Description
public
TextExtractor(@NonNull PDPage
the page the annotation is on, must not be null
page
,
@NonNull COSArray
the raw annotation, must not be null
boundingBoxes
)

Method Summary

Modifier and TypeMethod and Description
private Rectangle2D
calculateSegmentBoundingBox(COSArray quadsArray, int segmentPointer)

public String

Returns:

The text of the annotation
extractMarkedText
()

Extracts the text of a marked annotation such as highlights, underlines, strikeouts etc.

private float
toFloat(Object cosNumber)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundingBoxesback to summary
private final COSArray boundingBoxes
pageback to summary
private final PDPage page

Constructor Detail

TextExtractorback to summary
public TextExtractor(@NonNull PDPage page, @NonNull COSArray boundingBoxes)
Parameters
page:@NonNull PDPage

the page the annotation is on, must not be null

boundingBoxes:@NonNull COSArray

the raw annotation, must not be null

Method Detail

calculateSegmentBoundingBoxback to summary
private Rectangle2D calculateSegmentBoundingBox(COSArray quadsArray, int segmentPointer)
extractMarkedTextback to summary
public String extractMarkedText() throws IOException

Extracts the text of a marked annotation such as highlights, underlines, strikeouts etc.

Returns:String

The text of the annotation

Exceptions
IOException:
If the PDFTextStripperByArea fails to initialize.
toFloatback to summary
private float toFloat(Object cosNumber)