title: ODT to PDF conversion using PHP/OO
body: <p>I am currently trying to convert an ODT to PDF using OO silently from PHP. Here is the code for that:</p>
  
  <pre><code>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 odt2pdf($doc_url, $output_url){
  $osm = new COM("com.sun.star.ServiceManager") or die ("Please be sure that OpenOffice.org is installed.\n");
  $args = array(MakePropertyValue("Hidden",true,$osm));
  $oDesktop = $osm-&gt;createInstance("com.sun.star.frame.Desktop");
  $oWriterDoc = $oDesktop-&gt;loadComponentFromURL($doc_url,"_blank", 0, $args);
  $aFilterData  = array();
  $aFilterData [0] = $osm-&gt;Bridge_GetStruct("com.sun.star.beans.PropertyValue");
  $aFilterData [0]-&gt;Name = "SelectPdfVersion";
  $aFilterData [0]-&gt;Value = 1;
  $obj  = $osm-&gt;Bridge_GetValueObject();
  $obj-&gt;set("[]com.sun.star.beans.PropertyValue",$aFilterData );
  $storePDF = array();
  $storePDF[0] = $osm-&gt;Bridge_GetStruct("com.sun.star.beans.PropertyValue");
  $storePDF[0]-&gt;Name = "FilterName";
  $storePDF[0]-&gt;Value = "writer_pdf_Export";
  $storePDF[1] = $osm-&gt;Bridge_GetStruct("com.sun.star.beans.PropertyValue");   
  $storePDF[1]-&gt;Name = "FilterData";
  $storePDF[1]-&gt;Value = $obj;
  $oWriterDoc-&gt;storeToURL($output_url,$storePDF);
  $oWriterDoc-&gt;close(true);
  }
  $output_dir = "C:/wamp/www/cert/pdf/";
  $doc_file = "C:/wamp/www/cert/output2.odt";
  $pdf_file = "output2.pdf";
  $output_file = $output_dir . $pdf_file;
  $doc_file = "file:///" . $doc_file;
  $output_file = "file:///" . $output_file;
  odt2pdf($doc_file,$output_file);
  </code></pre>
  
  <p>I have managed to get it to convert to PDF/A-1a as can be seen, however it still does not preserve the fonts being used. If I convert this from within the GUI in Open Office, then the fonts are kept. What's wrong?</p>
  
  <p><strong>UPDATE:</strong> I decided to stop converting to PDF and do a silent print of the odt to the printer with Open Office using exec() in PHP.</p>
  
  <p>As an additional note, make sure to switch off Font substitution on the printer driver to prevent any font substitution when printing to a PostScript printer.</p>