Top Description Fields Constructors Methods
org.apache.pdfbox.text

pack-priv Class LegacyPDFStreamEngine

extends PDFStreamEngine
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.text.PDFMarkedContentExtractor, org.apache.pdfbox.text.PDFTextStripper
Imports
java.io.IOException, .InputStream, java.util.Map, .WeakHashMap, org.apache.commons.logging.Log, .LogFactory, org.apache.fontbox.ttf.TrueTypeFont, org.apache.fontbox.util.BoundingBox, org.apache.pdfbox.contentstream.PDFStreamEngine, org.apache.pdfbox.pdmodel.PDPage, org.apache.pdfbox.pdmodel.font.encoding.GlyphList, org.apache.pdfbox.pdmodel.common.PDRectangle, org.apache.pdfbox.pdmodel.font.PDCIDFont, .PDCIDFontType2, .PDFont, .PDSimpleFont, .PDTrueTypeFont, .PDType0Font, .PDType3Font, .PDFontDescriptor, org.apache.pdfbox.pdmodel.graphics.state.PDGraphicsState, org.apache.pdfbox.util.Matrix, .Vector, org.apache.pdfbox.contentstream.operator.DrawObject, org.apache.pdfbox.contentstream.operator.state.Concatenate, .Restore, .Save, .SetGraphicsStateParameters, .SetMatrix, org.apache.pdfbox.contentstream.operator.text.BeginText, .EndText, .SetFontAndSize, .SetTextHorizontalScaling, .ShowTextAdjusted, .ShowTextLine, .ShowTextLineAndSpace, .MoveText, .MoveTextSetLeading, .NextLine, .SetCharSpacing, .SetTextLeading, .SetTextRenderingMode, .SetTextRise, .SetWordSpacing, .ShowText, org.apache.pdfbox.cos.COSDictionary

LEGACY text calculations which are known to be incorrect but are depended on by PDFTextStripper. This class exists only so that we don't break the code of users who have their own subclasses of PDFTextStripper. It replaces the mostly empty implementation of showGlyph() in PDFStreamEngine with a heuristic implementation which is backwards compatible. DO NOT USE THIS CODE UNLESS YOU ARE WORKING WITH PDFTextStripper. THIS CODE IS DELIBERATELY INCORRECT, USE PDFStreamEngine INSTEAD.

Field Summary

Modifier and TypeField and Description
private final Map<COSDictionary, Float>
private static final GlyphList
private static final Log
private int
private PDRectangle
private Matrix

Constructor Summary

AccessConstructor and Description
pack-priv
LegacyPDFStreamEngine()

Constructor.

Method Summary

Modifier and TypeMethod and Description
protected float

Returns:

the font height.
computeFontHeight
(PDFont
the font.
font
)

Compute the font height.

public void
processPage(PDPage
the page to process
page
)

Overrides org.apache.pdfbox.contentstream.PDFStreamEngine.processPage.

This will initialize and process the contents of the stream.

protected void
processTextPosition(TextPosition
The text to be processed.
text
)

A method provided as an event interface to allow a subclass to perform some specific functionality when text needs to be processed.

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.contentstream.PDFStreamEngine.showGlyph.

Called when a glyph is to be processed.

Inherited from org.apache.pdfbox.contentstream.PDFStreamEngine:
addOperatorapplyTextAdjustmentbeginMarkedContentSequencebeginTextdecreaseLevelendMarkedContentSequenceendTextgetAppearancegetCurrentPagegetGraphicsStackSizegetGraphicsStategetInitialMatrixgetLevelgetResourcesgetTextLineMatrixgetTextMatrixincreaseLevelisShouldProcessColorOperatorsoperatorExceptionprocessAnnotationprocessChildStreamprocessOperatorprocessOperatorprocessSoftMaskprocessTilingPatternprocessTilingPatternprocessTransparencyGroupprocessType3StreamrestoreGraphicsStackrestoreGraphicsStatesaveGraphicsStacksaveGraphicsStatesetLineDashPatternsetTextLineMatrixsetTextMatrixshowAnnotationshowFontGlyphshowFormshowTextshowTextStringshowTextStringsshowTransparencyGroupshowType3GlyphtransformedPointtransformWidthunsupportedOperator

Field Detail

fontHeightMapback to summary
private final Map<COSDictionary, Float> fontHeightMap
GLYPHLISTback to summary
private static final GlyphList GLYPHLIST
LOGback to summary
private static final Log LOG

Hides org.apache.pdfbox.contentstream.PDFStreamEngine.LOG.

pageRotationback to summary
private int pageRotation
pageSizeback to summary
private PDRectangle pageSize
translateMatrixback to summary
private Matrix translateMatrix

Constructor Detail

LegacyPDFStreamEngineback to summary
pack-priv LegacyPDFStreamEngine()

Constructor.

Method Detail

computeFontHeightback to summary
protected float computeFontHeight(PDFont font) throws IOException

Compute the font height. Override this if you want to use own calculations.

Parameters
font:PDFont

the font.

Returns:float

the font height.

Exceptions
IOException:
if there is an error while getting the font bounding box.
processPageback to summary
public void processPage(PDPage page) throws IOException

Overrides org.apache.pdfbox.contentstream.PDFStreamEngine.processPage.

This will initialize and process the contents of the stream.

Parameters
page:PDPage

the page to process

Annotations
@Override
Exceptions
IOException:
if there is an error accessing the stream.
processTextPositionback to summary
protected void processTextPosition(TextPosition text)

A method provided as an event interface to allow a subclass to perform some specific functionality when text needs to be processed.

Parameters
text:TextPosition

The text to be processed.

showGlyphback to summary
protected void showGlyph(Matrix textRenderingMatrix, PDFont font, int code, Vector displacement) throws IOException

Overrides org.apache.pdfbox.contentstream.PDFStreamEngine.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