nezinu vai strādā.. bet...
function html2rtf ( $html ) {
$startpos = strpos($html,'<');
$rtf = '';
while ( $startpos !== false ) {
// get tag
$endpos = strpos($html,'>',$startpos);
if ($endpos !== false) {
$tag = substr($html,$startpos+1,$endpos - $startpos - 1);
$rtf .= substr($html,0,$startpos);
switch (strtoupper($tag)) {
case 'P':
break;
case '/P':
$rtf .= ' \par ';
break;
case 'BR':
$rtf .= ' \line ';
break;
case 'B':
$rtf .= '{\b ';
break;
case '/B':
$rtf .= '}';
break;
case 'STRONG':
$rtf .= '{\b ';
break;
case '/STRONG':
$rtf .= '} ';
break;
case 'I':
$rtf .= '{\i ';
break;
case '/I':
$rtf .= '}';
break;
case 'EM':
$rtf .= '{\i ';
break;
case '/EM':
$rtf .= '}';
break;
case 'U':
$rtf .= '{\ul ';
break;
case '/U':
$rtf .= '}';
break;
case 'OL':
$listnumber = 1;
$listtype = 'number';
break;
case '/OL':
break;
case 'UL':
$listtype = 'bullet';
break;
case '/UL':
break;
case 'LI':
switch ($listtype) {
case 'number':
$bullet = "$listnumber.";
$listnumber++;
break;
default:
$bullet = '\bullet ';
break;
}
$rtf .= ' \fi-400\li400{'. $bullet .'\tab ';
break;
case '/LI':
$rtf .= '}\par ';
break;
case '/TD':
$rtf .= ' ';
break;
case '/TR':
$rtf .= ' \par ';
break;
}
$html = substr($html, $endpos + 1);
$startpos = strpos($html,'<');
} else {
$startpos = false;
}
}
// append remaining text
$rtf .= $html;
return $rtf;
}