Top Description Fields Constructors Methods
org.apache.pdfbox.examples.util

public Class PrintTextColors

extends PDFTextStripper
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .File, .IOException, .OutputStreamWriter, .Writer, org.apache.pdfbox.Loader, org.apache.pdfbox.contentstream.operator.color.SetNonStrokingColor, .SetNonStrokingColorN, .SetNonStrokingColorSpace, .SetNonStrokingDeviceCMYKColor, .SetNonStrokingDeviceGrayColor, .SetNonStrokingDeviceRGBColor, .SetStrokingColor, .SetStrokingColorN, .SetStrokingColorSpace, .SetStrokingDeviceCMYKColor, .SetStrokingDeviceGrayColor, .SetStrokingDeviceRGBColor, org.apache.pdfbox.pdmodel.PDDocument, org.apache.pdfbox.pdmodel.graphics.color.PDColor, org.apache.pdfbox.pdmodel.graphics.state.RenderingMode, org.apache.pdfbox.text.PDFTextStripper, .TextPosition

This is an example on how to get the colors of text. Note that this will not tell the background, and will only work properly if the text is not overwritten later, and only if the text rendering modes are 0, 1 or 2. In the PDF 32000 specification, please read 9.3.6 "Text Rendering Mode" to know more. Mode 0 (FILL) is the default. Mode 1 (STROKE) will make glyphs look "hollow". Mode 2 (FILL_STROKE) will make glyphs look "fat".
Authors
Ben Litchfield, Tilman Hausherr

Field Summary

Inherited from org.apache.pdfbox.text.PDFTextStripper:
charactersByArticledocumentLINE_SEPARATORoutput

Constructor Summary

AccessConstructor and Description
public
PrintTextColors()

Instantiate a new PDFTextStripper object.

Method Summary

Modifier and TypeMethod and Description
public static void
main(String[]
The command line arguments.
args
)

This will print the documents data.

protected void
processTextPosition(TextPosition
The text to process.
text
)

Overrides org.apache.pdfbox.text.PDFTextStripper.processTextPosition.

This will process a TextPosition object and add the text to the list of characters on a page.

private static void
usage()

This will print the usage for this document.

Inherited from org.apache.pdfbox.text.PDFTextStripper:
beginMarkedContentSequenceendArticleendDocumentendMarkedContentSequenceendPagegetAddMoreFormattinggetArticleEndgetArticleStartgetAverageCharTolerancegetCharactersByArticlegetCurrentPageNogetDropThresholdgetEndBookmarkgetEndPagegetIgnoreContentStreamSpaceGlyphsgetIndentThresholdgetLineSeparatorgetListItemPatternsgetOutputgetPageEndgetPageStartgetParagraphEndgetParagraphStartgetSeparateByBeadsgetSortByPositiongetSpacingTolerancegetStartBookmarkgetStartPagegetSuppressDuplicateOverlappingTextgetTextgetWordSeparatormatchPatternprocessPageprocessPagessetAddMoreFormattingsetArticleEndsetArticleStartsetAverageCharTolerancesetDropThresholdsetEndBookmarksetEndPagesetIgnoreContentStreamSpaceGlyphssetIndentThresholdsetLineSeparatorsetListItemPatternssetPageEndsetPageStartsetParagraphEndsetParagraphStartsetShouldSeparateByBeadssetSortByPositionsetSpacingTolerancesetStartBookmarksetStartPagesetSuppressDuplicateOverlappingTextsetWordSeparatorstartArticlestartArticlestartDocumentstartPagewriteCharacterswriteLineSeparatorwritePagewritePageEndwritePageStartwriteParagraphEndwriteParagraphSeparatorwriteParagraphStartwriteStringwriteStringwriteTextwriteWordSeparator

Constructor Detail

PrintTextColorsback to summary
public PrintTextColors() throws IOException

Instantiate a new PDFTextStripper object.

Exceptions
IOException:
If there is an error loading the properties.

Method Detail

mainback to summary
public static void main(String[] args) throws IOException

This will print the documents data.

Parameters
args:String[]

The command line arguments.

Exceptions
IOException:
If there is an error parsing the document.
processTextPositionback to summary
protected void processTextPosition(TextPosition text)

Overrides org.apache.pdfbox.text.PDFTextStripper.processTextPosition.

Doc from org.apache.pdfbox.text.PDFTextStripper.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.

Parameters
text:TextPosition

The text to process.

Annotations
@Override
usageback to summary
private static void usage()

This will print the usage for this document.