0

This question is in reference to:

Free (preferably) PHP RTF to HTML converter?

I'm trying to execute that last line of code in my php:

exec(rtf2htm file.rtf file.html)

I understand what parameters need to go within the parentheses, I just do not know how to write it. I've looked at multiple examples along with the php documentation and still I remain confused, so could someone show me how it is written? rtf2htm refers to a PHP file which converts RTF to HTML.

Ultimately what I am trying to do is convert the content of numerous RTF docs to HTML, maintaining the formatting, while not creating tags such as<head> or <body> which programs like Word or TextEdit generate when converting to HTML.

Community
  • 1
  • 1
flatline_
  • 15
  • 2
  • exec("rtf2htm file.rtf file.html"); – Orangepill Jun 07 '13 at 19:01
  • @Orangepill `rtf2htm` alone gives me the error `not recognized as internal or external command.` My environment may be set up wrong, I don't know since I'm relatively new to coding. `rtf2htm\rtf2tm.php` does work though but only opens it in it's associated app instead of converting docs. – flatline_ Jun 07 '13 at 22:53

1 Answers1

0

rtf2htm is not a php script, it is a program installed on the server. exec() is used to call external applications.

EDIT: After looking up this script, it seems that it is indeed a php script. But it has been coded to be usable from the command line only.

This should work:

<?php

exec('php /path/to/rtf2htm /path/to/source.rtf /path/to/output.html');

?>
Alexandre Danault
  • 8,602
  • 3
  • 30
  • 33
  • `php` is giving me the error `not recognized as internal or external command.` Thanks for clarifying the code though, since `path/to/rtf2htm` is now opening the php file, but it only opens in its associated application (my IDE) instead of converting the docs. – flatline_ Jun 07 '13 at 23:00
  • replace php with the full path to the php executable, so you'd get `exec('/path/to/php /path/to/rtf2htm /path/to/source.rtf /path/to/output.html');` or `exec('/path/to/php.exe /path/to/rtf2htm /path/to/source.rtf /path/to/output.html');` on windows. – Alexandre Danault Jun 08 '13 at 00:47
  • `exec('Drive:/path/to/php.exe')` is allowing it to work, yet the scripts intended affect is not working. Something either is not being inputted correctly or there is a bug somewhere within it. Thanks for the help though. I'll post a solution if I find one. – flatline_ Jun 12 '13 at 04:09