PHP Classes

Word To Pdf

Recommend this page to a friend!

      wordDocumentHandler  >  All threads  >  Word To Pdf  >  (Un) Subscribe thread alerts  
Subject:Word To Pdf
Summary:Please help me to convert word file into pdf
Messages:2
Author:Abhinav Goel
Date:2008-12-08 13:15:11
Update:2009-04-14 17:40:16
 

  1. Word To Pdf   Reply   Report abuse  
Picture of Abhinav Goel Abhinav Goel - 2008-12-08 13:15:11
Hello Everybody
Please help me to convert word file into pdf file.

  2. Re: Word To Pdf   Reply   Report abuse  
Picture of Manuel Gotzen Manuel Gotzen - 2009-04-14 17:40:16 - In reply to message 1 from Abhinav Goel
The easiest way is the Windows PHP converter of Word documents to PDF using OpenOffice via a COM wrapper of the OpenOffice API's:

<?php
function MakePropertyValue($name,$value,$osm){
$oStruct = $osm->Bridge_GetStruct("com.sun.star.beans.PropertyValue");
$oStruct->Name = $name;
$oStruct->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->createInstance("com.sun.star.frame.Desktop");
//Load the .doc file, and pass in the "Hidden" property from above
$oWriterDoc = $oDesktop->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->storeToURL($output_url,$export_args);
$oWriterDoc->close(true);
}

?>