Home > Article > Backend Development > PHP converts html to rtf format_PHP tutorial
Preliminary preparations: Download Html2Rtf.dll, run cmd as administrator, enter the directory where Html2Rtf.dll is located -> Enter Regsvr32 Html2Rtf.dll
Core code:
PreserveImages = true;
$html2RTFCom->PageNumbers = 1;
$html2RTFCom->PageNumbersAlignH = 1;
$html2RTFCom->PageNumbersAlignV = 5;
$htmlFile = "a.html";
$rtfFile = "a.rtf";
$result =$html2RTFCom->ConvertFile($htmlFile,$rtfFile, "head", "foot");
print($result);
unset($html2RTFCom);
echo "done";
?>
Possible problems Fatal error: Class 'COM' not found in ×××
Solution:
·Copy php_com_dotnet.dll to the ext folder in the php root directory
·php.ini Make sure to have this statement
[PHP_COM_DOTNET]
extension=php_com_dotnet.dll
·Ensure that the COM+ Event System service is turned on