(I'm not sure if this forum is related to webdeveloper.com or not, but i'm posting here since there wasn't any response there)

No matter what I tried to call my open office macro, whether it's exec, shell_exec, system or even COM("WScript.Shell"), the command line seems to be ignored without returning any errors from php. Sometimes it just hangs!

It's running fine from command line itself. (im using php 5.2.6, winxp, apache)

  1. my php calls the following batch file through this :
$cmd = "c:\\php\\cmd.exe /c c:\\convert.cmd c:\myoutput.html";
$output = shell_exec($cmd);

  1. convert.cmd contains the following to convert html into word:
@ECHO OFF

"C:\\Program Files\\OpenOffice.org 3\\program\\soffice" -invisible -headless "macro:///Standard.Conversion.ConvertHTMLToWord(%1)"

echo "Converted!"

EXIT
  1. expected output on c:\ should have generated *.doc files but theres none. but i get a "Converted!" string back from $output. It seems to have ignored my macro call?

This doesn't happen if i call it directly through command prompt Or if i call it not through a web server such as :

<?php  

   $filename = $argv[1];

   $cmd = "c:\php\cmd.exe /c c:\convert.cmd $filename\n";

   echo $cmd;
   $output = shell_exec($cmd);

   print($output);
?>

then run with "C:\php\php c:\myoutput.html" it'll generate the doc file as well as "Converted!" string.

But what i really need is the ability to run it from apache hosted web server, through a web browser. How can i go about?

    can anyone help me out? I've been cracking my brain for the past two days and crawled through many forums and google searches I just feel that I'm so close to achieving what I needed, but alas the command prompt is not working.

    😕

    unless someone can tell me if there is another way to convert html directly into word doc / rtf with embedded images working.

      Write a Reply...