Question:
Is it possible to read an RTF file and rewrite it in TXT format, using PHP?
I did some tests using fopen()
and file_get_contents()
, but the results were not as expected.
Answer:
It would be easier if you used libraries for this purpose.
https://github.com/jstewmc/rtf
According to the example on Github, you can do:
$doc = new \Jstewmc\Rtf\Document();
$doc->load('/path/to/file.rtf');
$doc->write('text');