Documentation

Document
in package

RTF document reader.

References:

  • How to Write an RTF Reader http://latex2rtf.sourceforge.net/rtfspec_45.html
  • PHP rtfclass by Markus Fischer https://github.com/mfn/rtfclass
  • JavaScript RTF-parser by LazyGyu https://github.com/lazygyu/RTF-parser
Tags
since
0.11.0
SuppressWarnings

(PHPMD.UnusedPrivateMethod)

Table of Contents

Constants

PARA  = 'readParagraph'
SKIP  = 'readSkip'
STYL  = 'readStyle'

Properties

$rtf  : string
RTF content.
$control  : string
Current control word.
$flags  : array<string|int, mixed>
Parser flags; not used.
$groups  : array<string|int, mixed>
Group groups.
$isControl  : bool
Parsing a control word flag.
$isFirst  : bool
First character flag: watch out for control symbols.
$length  : int
Content length.
$offset  : int
Character index.
$phpWord  : PhpWord
PhpWord object.
$section  : Section
Section object.
$text  : string
Text content.
$textrun  : TextRun
Textrun object.

Methods

read()  : void
Parse RTF content.
flush()  : void
Flush control word or text.
flushControl()  : void
Flush control word.
flushText()  : void
Flush text in queue.
markBackslash()  : void
Mark backslash `\` character.
markClosing()  : void
Mark closing braket `}` character.
markNewline()  : void
Mark newline character: Flush control word because it's not possible to span multiline.
markOpening()  : void
Mark opening braket `{` character.
parseControl()  : void
Parse control.
pushText()  : void
Push text into queue.
readParagraph()  : void
Read paragraph.
readSkip()  : void
Read skip.
readStyle()  : void
Read style.
readText()  : void
Read text.
setControl()  : void
Reset control word and first char state.

Constants

PARA

public mixed PARA = 'readParagraph'
Tags
const

int

Properties

$control

Current control word.

private string $control = ''

$flags

Parser flags; not used.

private array<string|int, mixed> $flags = []

$groups

Group groups.

private array<string|int, mixed> $groups = []

$isControl

Parsing a control word flag.

private bool $isControl = false

$isFirst

First character flag: watch out for control symbols.

private bool $isFirst = false

$length

Content length.

private int $length = 0

$offset

Character index.

private int $offset = 0

$text

Text content.

private string $text = ''

Methods

read()

Parse RTF content.

public read(PhpWord $phpWord) : void
  • Marks controlling characters {, }, and \
  • Removes line endings
  • Builds control words and control symbols
  • Pushes every other character into the text queue
Parameters
$phpWord : PhpWord
Tags
todo

Use fread stream for scalability

flush()

Flush control word or text.

private flush([bool $isControl = false ]) : void
Parameters
$isControl : bool = false

flushControl()

Flush control word.

private flushControl([bool $isControl = false ]) : void
Parameters
$isControl : bool = false

flushText()

Flush text in queue.

private flushText() : void

markBackslash()

Mark backslash `\` character.

private markBackslash() : void

markClosing()

Mark closing braket `}` character.

private markClosing() : void

markNewline()

Mark newline character: Flush control word because it's not possible to span multiline.

private markNewline() : void

markOpening()

Mark opening braket `{` character.

private markOpening() : void

parseControl()

Parse control.

private parseControl(string $control, string $parameter) : void
Parameters
$control : string
$parameter : string

pushText()

Push text into queue.

private pushText(string $char) : void
Parameters
$char : string

readParagraph()

Read paragraph.

private readParagraph(array<string|int, mixed> $directives) : void
Parameters
$directives : array<string|int, mixed>

readSkip()

Read skip.

private readSkip(array<string|int, mixed> $directives) : void
Parameters
$directives : array<string|int, mixed>

readStyle()

Read style.

private readStyle(array<string|int, mixed> $directives) : void
Parameters
$directives : array<string|int, mixed>

readText()

Read text.

private readText() : void

setControl()

Reset control word and first char state.

private setControl(bool $value) : void
Parameters
$value : bool

        
On this page

Search results