Table of Contents

Class LocationTextExtractionStrategy

Namespace
iText.Kernel.Pdf.Canvas.Parser.Listener
Assembly
itext.kernel.dll
public class LocationTextExtractionStrategy : ITextExtractionStrategy, IEventListener
Inheritance
LocationTextExtractionStrategy
Implements
Inherited Members

Constructors

LocationTextExtractionStrategy()

Creates a new text extraction renderer.

public LocationTextExtractionStrategy()

LocationTextExtractionStrategy(ITextChunkLocationStrategy)

Creates a new text extraction renderer, with a custom strategy for creating new TextChunkLocation objects based on the input of the TextRenderInfo.

public LocationTextExtractionStrategy(LocationTextExtractionStrategy.ITextChunkLocationStrategy strat)

Parameters

strat LocationTextExtractionStrategy.ITextChunkLocationStrategy

the custom strategy

Methods

EventOccurred(IEventData, EventType)

public virtual void EventOccurred(IEventData data, EventType type)

Parameters

data IEventData
type EventType

GetResultantText()

public virtual string GetResultantText()

Returns

string

GetSupportedEvents()

public virtual ICollection<EventType> GetSupportedEvents()

Returns

ICollection<EventType>

IsChunkAtWordBoundary(TextChunk, TextChunk)

Determines if a space character should be inserted between a previous chunk and the current chunk.

protected virtual bool IsChunkAtWordBoundary(TextChunk chunk, TextChunk previousChunk)

Parameters

chunk TextChunk

the new chunk being evaluated

previousChunk TextChunk

the chunk that appeared immediately before the current chunk

Returns

bool

true if the two chunks represent different words (i.e. should have a space between them). False otherwise.

Remarks

Determines if a space character should be inserted between a previous chunk and the current chunk. This method is exposed as a callback so subclasses can fine time the algorithm for determining whether a space should be inserted or not. By default, this method will insert a space if the there is a gap of more than half the font space character width between the end of the previous chunk and the beginning of the current chunk. It will also indicate that a space is needed if the starting point of the new chunk appears before the end of the previous chunk (i.e. overlapping text).

IsUseActualText()

Gets the value of the property which determines if /ActualText will be used when extracting the text

public virtual bool IsUseActualText()

Returns

bool

true if /ActualText value is used, false otherwise

SetRightToLeftRunDirection(bool)

Sets if text flows from left to right or from right to left.

public virtual LocationTextExtractionStrategy SetRightToLeftRunDirection(bool rightToLeftRunDirection)

Parameters

rightToLeftRunDirection bool

value specifying whether the direction should be right to left

Returns

LocationTextExtractionStrategy

this object

Remarks

Sets if text flows from left to right or from right to left. Call this method with true argument for extracting Arabic, Hebrew or other text with right-to-left writing direction.

SetUseActualText(bool)

Changes the behavior of text extraction so that if the parameter is set to true , /ActualText marked content property will be used instead of raw decoded bytes.

public virtual LocationTextExtractionStrategy SetUseActualText(bool useActualText)

Parameters

useActualText bool

true to use /ActualText, false otherwise

Returns

LocationTextExtractionStrategy

this object

Remarks

Changes the behavior of text extraction so that if the parameter is set to true , /ActualText marked content property will be used instead of raw decoded bytes. Beware: the logic is not stable yet.