PHP code example of jstewmc / rtf-token

1. Go to this page and download the library: Download jstewmc/rtf-token library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jstewmc / rtf-token example snippets


namespace Jstewmc\RtfToken;

$open    = new Group\Open();
$control = new Control\Word('foo');
$text    = new Text('bar');
$close   = new Group\Close();

echo $open . $control . $text . $close;


namespace Jstewmc\RtfToken\Group;

(string) (new Open());   // returns "{"
(string) (new Close());  // returns "}"

namespace Jstewmc\RtfToken\Control;

$word = new Word('b', 0);

$word->getWord();       // returns "b"
$word->getParameter();  // returns 0

(string) $word;  // returns "\b0 "

$word->setIsSpaceDelimited(false);

(string) $word;  // returns "\b0" (note, no space)

namespace Jstewmc\RtfToken\Control;

$symbol = new Symbol('\'', 99);

$symbol->getSymbol();     // returns "'"
$symbol->getParameter();  // returns 99

(string) $symbol;  // returns "\'99 "

$symbol->setIsSpaceDelimited(false);

(string) $symbol;  // returns "\'99" (note, no space)

namespace Jstewmc\RtfToken;

$text = new Text('foo');

$text->getText();  // returns "foo"

(string) $text;  // returns "foo"

namespace Jstewmc\RtfToken;

$other = new Other("\n");

$other->getCharacter();  // returns "\n"

(string) $other;  // returns "\n"