An RTF to HTML converter in PHP
Este é um projeto proveniente do renck/rtfhtml onde consegui encontrar o que eu tanto precisava par aum projeto
Para usar o código:
use RtfHtmlPhp\Document;
$rtf = file_get_contents("test.rtf");
$document = new Document($rtf); // or use a string directlyDocument will raise an exception if the RTF document could not be parsed. Parse errors will generate PHP notices.
If you’d like to see what the parser read (for debug purposes), then call this:
echo $document;To convert the parser’s parse tree to HTML, call this (but only if the RTF was successfully parsed):
use RtfHtmlPhp\Html\HtmlFormatter;
$formatter = new HtmlFormatter();
echo $formatter->Format($document);For enhanced compatibility the default character encoding of the converted RTF unicode characters is set to HTML-ENTITIES. To change the default encoding, you can initialize the Html object with the desired encoding supported by mb_list_encodings(): ex. UTF-8
$formatter = new HtmlFormatter('UTF-8');composer require rafaelapuka/rtf-to-html- Please note that rtf-html-php requires your PHP installation to support the
mb_convert_encodingfunction. Therefore you must have thephp-mbstringmodule installed. For fresh PHP installations, it will usually be there.