java.lang.Object
org.sejda.sambox.contentstream.PDFStreamEngine
org.sejda.sambox.text.PDFTextStreamEngine
org.sejda.sambox.text.PDFTextStripper
org.sejda.sambox.text.PDFTextStripperByArea
This will extract text from a specified region in the PDF.
- Author:
- Ben Litchfield
-
Field Summary
Fields inherited from class org.sejda.sambox.text.PDFTextStripper
charactersByArticle, document, LINE_SEPARATOR, output -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddRegion(String regionName, Rectangle2D rect) Add a new region to group text by.voidextractRegions(PDPage page) Process the page to extract the region text.Get the list of regions that have been setup.getTextForRegion(String regionName) Get the text for the region, this should be called after extractRegions().protected voidThis will process a TextPosition object and add the text to the list of characters on a page.voidremoveRegion(String regionName) Delete a region to group text by.final voidsetShouldSeparateByBeads(boolean aShouldSeparateByBeads) This method does nothing in this derived class, because beads and regions are incompatible.protected voidThis will print the processed page text to the output stream.Methods inherited from class org.sejda.sambox.text.PDFTextStripper
endArticle, endDocument, endPage, getAddMoreFormatting, getArticleEnd, getArticleStart, getAverageCharTolerance, getCharactersByArticle, getCurrentPageNo, getDropThreshold, getEndBookmark, getEndPage, getIndentThreshold, getLineSeparator, getListItemPatterns, getOutput, getPageEnd, getPageStart, getParagraphEnd, getParagraphStart, getSeparateByBeads, getSortByPosition, getSpacingTolerance, getStartBookmark, getStartPage, getSuppressDuplicateOverlappingText, getText, getWordSeparator, matchPattern, processPage, processPages, setAddMoreFormatting, setArticleEnd, setArticleStart, setAverageCharTolerance, setDropThreshold, setEndBookmark, setEndPage, setIndentThreshold, setLineSeparator, setListItemPatterns, setPageEnd, setPageStart, setParagraphEnd, setParagraphStart, setSortByPosition, setSpacingTolerance, setStartBookmark, setStartPage, setSuppressDuplicateOverlappingText, setWordSeparator, startArticle, startArticle, startDocument, startPage, writeCharacters, writeLineSeparator, writePageEnd, writePageStart, writeParagraphEnd, writeParagraphSeparator, writeParagraphStart, writeString, writeString, writeText, writeWordSeparatorMethods inherited from class org.sejda.sambox.text.PDFTextStreamEngine
computeFontHeight, showGlyphMethods inherited from class org.sejda.sambox.contentstream.PDFStreamEngine
addOperator, addOperatorIfAbsent, applyTextAdjustment, beginMarkedContentSequence, beginText, decreaseLevel, endMarkedContentSequence, endText, getAppearance, getCurrentPage, getGraphicsStackSize, getGraphicsState, getInitialMatrix, getLevel, getResources, getTextLineMatrix, getTextMatrix, increaseLevel, operatorException, processAnnotation, processChildStream, processOperator, processOperator, processSoftMask, processStream, processTilingPattern, processTilingPattern, processTransparencyGroup, processType3Stream, restoreGraphicsStack, restoreGraphicsState, saveGraphicsStack, saveGraphicsState, setLineDashPattern, setTextLineMatrix, setTextMatrix, showAnnotation, showFontGlyph, showForm, showText, showTextString, showTextStrings, showTransparencyGroup, showType3Glyph, transformedPoint, transformWidth, unsupportedOperator
-
Constructor Details
-
PDFTextStripperByArea
Constructor.- Throws:
IOException- If there is an error loading properties.
-
-
Method Details
-
setShouldSeparateByBeads
public final void setShouldSeparateByBeads(boolean aShouldSeparateByBeads) This method does nothing in this derived class, because beads and regions are incompatible. Beads are ignored when stripping by area.- Overrides:
setShouldSeparateByBeadsin classPDFTextStripper- Parameters:
aShouldSeparateByBeads- The new grouping of beads.
-
addRegion
Add a new region to group text by.- Parameters:
regionName- The name of the region.rect- The rectangle area to retrieve the text from.
-
removeRegion
Delete a region to group text by. If the region does not exist, this method does nothing.- Parameters:
regionName- The name of the region to delete.
-
getRegions
Get the list of regions that have been setup.- Returns:
- A list of java.lang.String objects to identify the region names.
-
getTextForRegion
Get the text for the region, this should be called after extractRegions().- Parameters:
regionName- The name of the region to get the text from.- Returns:
- The text that was identified in that region.
-
extractRegions
Process the page to extract the region text.- Parameters:
page- The page to extract the regions from.- Throws:
IOException- If there is an error while extracting text.
-
processTextPosition
This will process a TextPosition object and add the text to the list of characters on a page. It takes care of overlapping text.- Overrides:
processTextPositionin classPDFTextStripper- Parameters:
text- The text to process.
-
writePage
This will print the processed page text to the output stream.- Overrides:
writePagein classPDFTextStripper- Throws:
IOException- If there is an error writing the text.
-