class Text implements ImageCollectorInterface

Class Text

Traits

Trait ImageCollectorTrait

Properties

protected array $collectedImages Array with all images used in command. from ImageCollectorTrait
protected Paragraph[] $paragraphs Paragraphs of text.
protected string $paragraphStyle Default paragraph style when adding text.
protected string $characterStyle Default character style when adding text.
protected bool $skipDetection Internal helper.
protected TextParser $htmlParser HTML parser instance.

Methods

array
getCollectedImages()

Returns collected images.

collectImageCommand(AbstractCommand $command)

Collects image in $command if $command is ImageBox

collectImage(ImageBox $imageBox)

Registers asset in $imageBox in $images.

addCollectedImages(mixed|ImageCollectorInterface $element)

If $element is instance of ImageCollectorInterface collectedImages will be added.

__construct(string $paragraphStyle = null, string $characterStyle = null)

Text constructor.

setParagraphStyle(string $paragraphStyle)

Sets default paragraph style.

setCharacterStyle(string $characterStyle)

Sets default character style.

clear()

Clears all content.

addParagraph(Paragraph $paragraph)

Adds $paragraph.

array
getParagraphs()

Returns all paragraphs.

addString(string $string, string $paragraphStyle = null, string $characterStyle = null)

Convenience method to transform $string to Text.

bool
isStringHtml(string $string)

Returns true if $string might be HTML.

addPlainText(string $string, string $paragraphStyle = null, string $characterStyle = null)

Adds $string as new paragraph.

addHtml(string $html, Style $style = null)

Parses $html and adds content as Paragraphs to instance.

getHtmlParser()

Returns html parser instance.

setHtmlParser(TextParser $parser)

Sets HTML parser instance.

parserFactory()

Html parser factory.

array
buildCommand()

Builds array that is sent as content parameter in TextBox commands to InDesign.

Details

in ImageCollectorTrait at line 39
array getCollectedImages()

Returns collected images.

Return Value

array

in ImageCollectorTrait at line 49
protected collectImageCommand(AbstractCommand $command)

Collects image in $command if $command is ImageBox

Parameters

AbstractCommand $command

in ImageCollectorTrait at line 61
protected collectImage(ImageBox $imageBox)

Registers asset in $imageBox in $images.

Parameters

ImageBox $imageBox

in ImageCollectorTrait at line 90
protected addCollectedImages(mixed|ImageCollectorInterface $element)

If $element is instance of ImageCollectorInterface collectedImages will be added.

Parameters

mixed|ImageCollectorInterface $element

at line 73
__construct(string $paragraphStyle = null, string $characterStyle = null)

Text constructor.

Parameters

string $paragraphStyle
string $characterStyle

at line 91
Text setParagraphStyle(string $paragraphStyle)

Sets default paragraph style.

Parameters

string $paragraphStyle

Return Value

Text

at line 105
Text setCharacterStyle(string $characterStyle)

Sets default character style.

Parameters

string $characterStyle

Return Value

Text

at line 117
Text clear()

Clears all content.

Return Value

Text

at line 132
Text addParagraph(Paragraph $paragraph)

Adds $paragraph.

Parameters

Paragraph $paragraph

Return Value

Text

at line 147
array getParagraphs()

Returns all paragraphs.

Return Value

array

at line 163
Text addString(string $string, string $paragraphStyle = null, string $characterStyle = null)

Convenience method to transform $string to Text.

If $string looks like HTML addHtml() is used. Otherwise $string is handled as plain text.

Parameters

string $string
string $paragraphStyle
string $characterStyle

Return Value

Text

Exceptions

Exception

at line 183
protected bool isStringHtml(string $string)

Returns true if $string might be HTML.

Parameters

string $string

Return Value

bool

at line 202
Text addPlainText(string $string, string $paragraphStyle = null, string $characterStyle = null)

Adds $string as new paragraph.

Parameters

string $string
string $paragraphStyle
string $characterStyle

Return Value

Text

Exceptions

Exception

at line 230
Text addHtml(string $html, Style $style = null)

Parses $html and adds content as Paragraphs to instance.

Parameters

string $html HTML string to add to Text instance.
Style $style Optional HTML Style applied to text.

Return Value

Text

Exceptions

Exception

at line 250
TextParser getHtmlParser()

Returns html parser instance.

If none is set new parser instance is created by the factory.

Return Value

TextParser

at line 266
Text setHtmlParser(TextParser $parser)

Sets HTML parser instance.

Parameters

TextParser $parser

Return Value

Text

at line 279
protected TextParser parserFactory()

Html parser factory.

Factory can be overwritten to have project specific parsers created automatically.

Return Value

TextParser

at line 290
array buildCommand()

Builds array that is sent as content parameter in TextBox commands to InDesign.

Return Value

array

Exceptions

Exception