SetaPDF_Extractor_Strategy_Word Extraction strategy for single words.

File: /SetaPDF/Extractor/Strategy/Word.php

The result of this strategy sorted from top-left to bottom-right.

Each word is represented by an instance of SetaPDF_Extractor_Result_Word.

This class allows you to receive a words boundary through the getBounds() method.

Class hierarchy

Summary

Constants

DETAIL_LEVEL_DEFAULT

Default detail level resulting in instances of SetaPDF_Extractor_Result_Word.

DETAIL_LEVEL_GLYPHS

Extended detail level resulting in instances of SetaPDF_Extractor_Result_WordWithGlyphs.


Static Properties

$characters

static public string SetaPDF_Extractor_Strategy_Word::$characters = '-‐−—‑²­'

In outdated PHP 5.2 version this property could be used to extend the character classes.

"\x2D" 'HYPHEN-MINUS' (U+002D) "\xE2\x80\x90" 'HYPHEN' (U+2010) "\xE2\x88\x92" 'MINUS SIGN' (U+2212) "\xE2\x80\x94" 'EM DASH' (U+2014) "\xE2\x80\x91" 'NON-BREAKING HYPHEN' (U+2011) "\xC2\xB2" 'SUPERSCRIPT TWO' (U+00B2) "\xC2\xAD" 'SOFT HYPHEN' (U+00AD)


Properties

$_cleanStreamCallback

A callback that is called before processing a stream.

$_detailLevel

protected string SetaPDF_Extractor_Strategy_Word::$_detailLevel = 'default'

The detail level.

$_graphicState

$_items

$_lastMatrix

$_resources

The stream resources dictionary.

$_sorter

$_textCount

A text item counter.

$spaceWidthFactor

The fonts space character width is devided by this factor to define the minimum space for a character separator.


Static Methods

_isNonWordCharacter()

static protected bool SetaPDF_Extractor_Strategy_Word::_isNonWordCharacter ( string $character )

Checks whether the character is a non word character.

Parameters
$character : string

$character

getWords()

static public array SetaPDF_Extractor_Strategy_Word::getWords ( $text $text [, string $encoding = 'UTF-8' ] )

Helper method to split a string into words.

This helper allows you to split a string into words with the same logic that is used to resolve words by text items resolved from a PDF document.

Parameters
$text : $text
 
$encoding : string
 

Methods

__construct()

The constructor.

_accept()

Proxy method that forwards the call to a filter instance if available.

Parameters
$textItem : SetaPDF_Extractor_TextItem
 
See

_cleanResult()

public string SetaPDF_Extractor_Strategy_Plain::_cleanResult ( $result $result )

Callback to clean up the resulting text.

Parameters
$result : $result
 

_getParser()

Creates the content stream parser.

Parameters
$stream : string
 

_getSubInstance()

Get an instance of the same strategy for processing an other stream (e.g. a Form XObject stream).

Parameters
$gs : SetaPDF_Core_Canvas_GraphicState
 

_onAfterShowText()

public void SetaPDF_Extractor_Strategy_Plain::_onAfterShowText ( string $rawString )

Callback that is called after a show text operation was invoked.

Parameters
$rawString : string
 

_onBeforeShowText()

Callback that is called before a show text operation is invoked.

_onBeginOrEndText()

public void SetaPDF_Extractor_Strategy_Plain::_onBeginOrEndText ( array $arguments, string $operator )

Callback for begin or end text operators (BT/ET).

Parameters
$arguments : array
 
$operator : string
 

_onCurrentTransformationMatrix()

public void SetaPDF_Extractor_Strategy_Plain::_onCurrentTransformationMatrix ( array $arguments, string $operator )

Callback for ctm changes (cm).

Parameters
$arguments : array
 
$operator : string
 

_onFormXObject()

public void SetaPDF_Extractor_Strategy_Plain::_onFormXObject ( array $arguments, string $operator )

Callback for painting a specified XObject.

Parameters
$arguments : array
 
$operator : string
 
Exceptions

Throws SetaPDF_Exception_NotImplemented

_onGraphicStateChange()

public void SetaPDF_Extractor_Strategy_Plain::_onGraphicStateChange ( array $arguments, string $operator )

Callback for graphic state changes operators (q/Q).

Parameters
$arguments : array
 
$operator : string
 

_onInlineImage()

public void SetaPDF_Extractor_Strategy_Plain::_onInlineImage ( array $arguments, string $operator )

Callback for inline image operator

Parameters
$arguments : array
 
$operator : string
 

_onTextPosition()

public void SetaPDF_Extractor_Strategy_Plain::_onTextPosition ( array $arguments, string $operator )

Callback for text position operators.

Parameters
$arguments : array
 
$operator : string
 

_onTextShow()

public void SetaPDF_Extractor_Strategy_Glyph::_onTextShow ( string $arguments, mixed $operator )

Callback that is called if a text should be shown.

Parameters
$arguments : string
 
$operator : mixed
 

_onTextState()

public void SetaPDF_Extractor_Strategy_Plain::_onTextState ( array $arguments, string $operator )

Callback for text state operators.

All states has to be passed to the current graphic state as defined in PDF 32000-1:2008, Table 52 on page 121.

Parameters
$arguments : array
 
$operator : string
 
Exceptions

Throws SetaPDF_Extractor_Exception

_saveLastMatrix()

protected void SetaPDF_Extractor_Strategy_Plain::_saveLastMatrix ( string $type )

Saves the last matrix by a specific type.

Parameters
$type : string
 

_showText()

protected void SetaPDF_Extractor_Strategy_Glyph::_showText ( $string $string )

Method that shows text.

Parameters
$string : $string
 

_showTextStrings()

public void SetaPDF_Extractor_Strategy_Glyph::_showTextStrings ( array $textStrings )

Callback that is called if text strings should be shown.

Parameters
$textStrings : array
 

getCleanStreamCallback()

Get the callback that is called before a stream is processed.

getDetailLevel()

Get the detail level of the expected result.

getGraphicState()

getResult()

Get all resolved words.

Parameters
$stream : string
 
$resources : SetaPDF_Core_Type_Dictionary
 

getSorter()

Get the sorter instance.

If none was set a base line sorter is created automatically.

process()

Processes a stream through the plain text strategy.

Parameters
$stream : string
 
$resources : SetaPDF_Core_Type_Dictionary
 

setCleanStreamCallback()

public void SetaPDF_Extractor_Strategy_AbstractStrategy::setCleanStreamCallback ( [ callable|null $callback = null ] )

Set a callback that is called before processing a stream.

Parameters
$callback : callable|null
 

setDetailLevel()

public void SetaPDF_Extractor_Strategy_Word::setDetailLevel ( string $detailLevel )

Set the detail level of the result.

Parameters
$detailLevel : string
 

setFilter()

setGraphicState()

Set the graphic state.

Parameters
$graphicState : SetaPDF_Core_Canvas_GraphicState
 

setSorter()

Set a sorter instance.

Parameters
$sorter : SetaPDF_Extractor_Sorter