Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I convert RTF to PDF from my PHP web page using OpenOffice?
    primarykey
    data
    text
    <p>My OS is Windows XP, and I'm using IIS 5.1 and PHP 5.2.9. I'm trying to call a PHP script from my PHP page in order to convert an RTF doc to a PDF, using OpenOffice. The script works just fine when I call it directly from the command line, but I'm not having any success getting the very same script to work when launched from my PHP web page. </p> <p>When I call the script from my PHP page, the page hangs, eventually showing an error, and I've noted that I can see in the Task Manager where the soffice.bin and soffice.exe processes are running under my IIS user name. </p> <p>This is the error:</p> <pre><code>Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `com.sun.star.ServiceManager': Server execution failed ' in C:\WEB_ROOT\SoftwareContract\WordToPdf.php:14 Stack trace: #0 C:\WEB_ROOT\SoftwareContract\WordToPdf.php(14): com-&gt;com('com.sun.star.Se...') #1 C:\WEB_ROOT\SoftwareContract\Index.php(11): word2pdf('file:///C:/web_...', 'file:///C:/web_...') #2 {main} thrown in C:\WEB_ROOT\SoftwareContract\WordToPdf.php on line 14 </code></pre> <p>I've double-checked permissions for my IIS user in these areas:</p> <pre><code>C:\PHP C:\Program Files\OpenOffice.org 3 C:\Program Files\Java C:\WEB_ROOT ---- location for my php code </code></pre> <p>In each case, my IIS user has these permissions: Read and Execute, List Folder Contents, Read. And in each case there are no "denys" checked to offset the permissions. I also gave the IIS user write permissions for the Web_Root folder where the php code resides.</p> <p>This is the php which calls the conversion function, WordToPdf:</p> <pre><code>&lt;?php require_once('WordToPdf.php'); $output_dir = 'C:/web_root/softwarecontract/'; $doc_file = 'C:/web_root/softwarecontract/testdoc.rtf'; $pdf_file = 'output.pdf'; $output_file = $output_dir . $pdf_file; $doc_file = "file:///" . $doc_file; $output_file = "file:///" . $output_file; word2pdf($doc_file,$output_file); ?&gt; </code></pre> <p>And this is WordToPdf.php:</p> <pre><code>&lt;?php set_time_limit(0); function MakePropertyValue($name,$value,$osm) { $oStruct = $osm-&gt;Bridge_GetStruct("com.sun.star.beans.PropertyValue"); $oStruct-&gt;Name = $name; $oStruct-&gt;Value = $value; return $oStruct; } function word2pdf($doc_url, $output_url) { //Invoke the OpenOffice.org service manager $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n"); //Set the application to remain hidden to avoid flashing the document onscreen $args = array(MakePropertyValue("Hidden",true,$osm)); //Launch the desktop $oDesktop = $osm-&gt;createInstance("com.sun.star.frame.Desktop"); //Load the .doc file, and pass in the "Hidden" property from above $oWriterDoc = $oDesktop-&gt;loadComponentFromURL($doc_url,"_blank", 0, $args); //Set up the arguments for the PDF output $export_args = array(MakePropertyValue("FilterName","writer_pdf_Export",$osm)); //Write out the PDF $oWriterDoc-&gt;storeToURL($output_url,$export_args); $oWriterDoc-&gt;close(true); } ?&gt; </code></pre> <p>Are there any problems with my permissions, or any additional areas where I need to check permissions for the IIS user? Does anyone have an idea why IIS failed to create the COM object, if not a permissions issue?</p> <p>Thanks!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload