From a REST API call I get a description text in RTF format. Just as a test, I have added just a small bitmap image (2x3 pixels in red) to that description. This returns the following RTF format string:
{\rtf1\fbidis\ansi\ansicpg0\uc1\deff0\deflang0\deflangfe0{\fonttbl{\f0\fnil Arial;}}{\colortbl;} \pard\fi0\li0\ql\ri0\sb0\sa0\itap0 {\pict\picwgoal30\pichgoal45\dibitmap0\wbmwidthbytes8\picw2\pich3 28000000020000000300000001002000000000001800000000000000000000000000000000000000241CED00241CED00241CED00241CED00241CED00241CED00}\par}
If a put this string in an ascii file and set the extension to *.rtf and open it in WordPad I get the expected result, a document with just a small red image.
I would like to be able to convert this RTF string to HTML using PHP. I have tried the roundcube/rtf-html-php package (ExtractImage() and PrintImage()), even modified it, without success. It looks like the RTF file string doesn't include the full bitmap file, maybe it's missing the header. Because if I open the bitmap file in a hex editor, I can see additional 14 bytes in the beginning compared to the data in the RTF file string:
I have looked at imagecreatefromstring() but it also requires the full image file as input.
How can I solve this?
