Document
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
Table of Contents
- PARA = 'readParagraph'
- SKIP = 'readSkip'
- STYL = 'readStyle'
- $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
- read() : mixed
- Parse RTF content
- flush() : mixed
- Flush control word or text.
- flushControl() : mixed
- Flush control word.
- flushText() : mixed
- Flush text in queue.
- markBackslash() : mixed
- Mark backslash `\` character.
- markClosing() : mixed
- Mark closing braket `}` character.
- markNewline() : mixed
- Mark newline character: Flush control word because it's not possible to span multiline.
- markOpening() : mixed
- Mark opening braket `{` character.
- parseControl() : mixed
- Parse control.
- pushText() : mixed
- Push text into queue.
- readParagraph() : mixed
- Read paragraph.
- readSkip() : mixed
- Read skip.
- readStyle() : mixed
- Read style.
- readText() : mixed
- Read text.
- setControl() : mixed
- Reset control word and first char state.
Constants
PARA
public
mixed
PARA
= 'readParagraph'
Tags
SKIP
public
mixed
SKIP
= 'readSkip'
STYL
public
mixed
STYL
= 'readStyle'
Properties
$rtf
RTF content
public
string
$rtf
$control
Current control word
private
string
$control
= ''
$flags
Parser flags; not used
private
array<string|int, mixed>
$flags
= array()
$groups
Group groups
private
array<string|int, mixed>
$groups
= array()
$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
$phpWord
PhpWord object
private
PhpWord
$phpWord
$section
Section object
private
Section
$section
$text
Text content
private
string
$text
= ''
$textrun
Textrun object
private
TextRun
$textrun
Methods
read()
Parse RTF content
public
read(PhpWord $phpWord) : mixed
- 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
Return values
mixed —flush()
Flush control word or text.
private
flush([bool $isControl = false ]) : mixed
Parameters
- $isControl : bool = false
Return values
mixed —flushControl()
Flush control word.
private
flushControl([bool $isControl = false ]) : mixed
Parameters
- $isControl : bool = false
Return values
mixed —flushText()
Flush text in queue.
private
flushText() : mixed
Return values
mixed —markBackslash()
Mark backslash `\` character.
private
markBackslash() : mixed
Return values
mixed —markClosing()
Mark closing braket `}` character.
private
markClosing() : mixed
Return values
mixed —markNewline()
Mark newline character: Flush control word because it's not possible to span multiline.
private
markNewline() : mixed
Return values
mixed —markOpening()
Mark opening braket `{` character.
private
markOpening() : mixed
Return values
mixed —parseControl()
Parse control.
private
parseControl(string $control, string $parameter) : mixed
Parameters
- $control : string
- $parameter : string
Return values
mixed —pushText()
Push text into queue.
private
pushText(string $char) : mixed
Parameters
- $char : string
Return values
mixed —readParagraph()
Read paragraph.
private
readParagraph(array<string|int, mixed> $directives) : mixed
Parameters
- $directives : array<string|int, mixed>
Return values
mixed —readSkip()
Read skip.
private
readSkip(array<string|int, mixed> $directives) : mixed
Parameters
- $directives : array<string|int, mixed>
Return values
mixed —readStyle()
Read style.
private
readStyle(array<string|int, mixed> $directives) : mixed
Parameters
- $directives : array<string|int, mixed>
Return values
mixed —readText()
Read text.
private
readText() : mixed
Return values
mixed —setControl()
Reset control word and first char state.
private
setControl(bool $value) : mixed
Parameters
- $value : bool