Top Description Inners Fields Constructors Methods
org.apache.pdfbox.debugger.pagepane

pack-priv final Class DebugTextOverlay

extends Object
Class Inheritance
Imports
java.awt.BasicStroke, .Color, .Graphics2D, .Shape, .Stroke, java.awt.geom.AffineTransform, .GeneralPath, .Rectangle2D, java.io.ByteArrayOutputStream, .IOException, .OutputStreamWriter, .Writer, java.util.List, org.apache.commons.logging.Log, .LogFactory, org.apache.fontbox.util.BoundingBox, org.apache.pdfbox.pdmodel.PDDocument, .PDPage, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.pdmodel.font.PDFont, .PDType3CharProc, .PDType3Font, .PDVectorFont, org.apache.pdfbox.pdmodel.interactive.pagenavigation.PDThreadBead, org.apache.pdfbox.text.PDFTextStripper, .TextPosition, org.apache.pdfbox.util.Matrix, .Vector

Draws an overlay showing the locations of text found by PDFTextStripper and another heuristic.
Authors
Ben Litchfield, Tilman Hausherr, John Hewson

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final PDDocument
private static final Log
private final int
private final float
private final boolean
private final boolean
private final boolean
private final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
DebugTextOverlay(PDDocument document, int pageIndex, float scale, boolean showTextStripper, boolean showTextStripperBeads, boolean showFontBBox, boolean showGlyphBounds)

Method Summary

Modifier and TypeMethod and Description
public void
renderTo(Graphics2D graphics)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

documentback to summary
private final PDDocument document
LOGback to summary
private static final Log LOG
pageIndexback to summary
private final int pageIndex
scaleback to summary
private final float scale
showFontBBoxback to summary
private final boolean showFontBBox
showGlyphBoundsback to summary
private final boolean showGlyphBounds
showTextStripperback to summary
private final boolean showTextStripper
showTextStripperBeadsback to summary
private final boolean showTextStripperBeads

Constructor Detail

DebugTextOverlayback to summary
pack-priv DebugTextOverlay(PDDocument document, int pageIndex, float scale, boolean showTextStripper, boolean showTextStripperBeads, boolean showFontBBox, boolean showGlyphBounds)

Method Detail

renderToback to summary
public void renderTo(Graphics2D graphics) throws IOException
org.apache.pdfbox.debugger.pagepane back to summary

private Class DebugTextOverlay.DebugTextStripper

extends PDFTextStripper
Class Inheritance

Field Summary

Modifier and TypeField and Description
private AffineTransform
private final Graphics2D
private AffineTransform
Inherited from org.apache.pdfbox.text.PDFTextStripper:
charactersByArticledocumentLINE_SEPARATORoutput

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private Shape
calculateGlyphBounds(AffineTransform at, PDFont font, int code, Vector displacement)

protected void
showGlyph(Matrix
the current text rendering matrix, Trm
textRenderingMatrix
,
PDFont
the current font
font
,
int
internal PDF character code for the glyph
code
,
Vector
the displacement (i.e. advance) of the glyph in text space
displacement
)

Overrides org.apache.pdfbox.text.LegacyPDFStreamEngine.showGlyph.

Called when a glyph is to be processed.

public void
stripPage(PDDocument document, PDPage page, int pageIndex, float scale)

private void
transform(Graphics2D graphics, PDPage page, float scale)

protected void
writeString(String
The text to write to the stream.
string
,
List<TextPosition>
The TextPositions belonging to the text.
textPositions
)

Overrides org.apache.pdfbox.text.PDFTextStripper.writeString.

Write a Java string to the output stream.

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

Field Detail

flipATback to summary
private AffineTransform flipAT
graphicsback to summary
private final Graphics2D graphics
transATback to summary
private AffineTransform transAT

Constructor Detail

DebugTextStripperback to summary
pack-priv DebugTextStripper(Graphics2D graphics)

Method Detail

calculateGlyphBoundsback to summary
private Shape calculateGlyphBounds(AffineTransform at, PDFont font, int code, Vector displacement) throws IOException
showGlyphback to summary
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException

Overrides org.apache.pdfbox.text.LegacyPDFStreamEngine.showGlyph.

Doc from org.apache.pdfbox.text.LegacyPDFStreamEngine.showGlyph.

Called when a glyph is to be processed. The heuristic calculations here were originally written by Ben Litchfield for PDFStreamEngine.

Parameters
textRenderingMatrix:Matrix

Doc from org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph.

the current text rendering matrix, Trm

font:PDFont

Doc from org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph.

the current font

code:int

Doc from org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph.

internal PDF character code for the glyph

displacement:Vector

Doc from org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph.

the displacement (i.e. advance) of the glyph in text space

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.pdfbox.contentstream.PDFStreamEngine.showGlyph.

if the glyph cannot be processed

stripPageback to summary
public void stripPage(PDDocument document, PDPage page, int pageIndex, float scale) throws IOException
transformback to summary
private void transform(Graphics2D graphics, PDPage page, float scale)
writeStringback to summary
protected void writeString(String string, List<TextPosition> textPositions) throws IOException

Overrides org.apache.pdfbox.text.PDFTextStripper.writeString.

Doc from org.apache.pdfbox.text.PDFTextStripper.writeString.

Write a Java string to the output stream. The default implementation will ignore the textPositions and just calls writeString(String).

Parameters
string:String

The text to write to the stream.

textPositions:List<TextPosition>

The TextPositions belonging to the text.

Annotations
@Override
Exceptions
IOException:
If there is an error when writing the text.