PHP处理Word转PDF的方法

  我们知道,PHP语言的合理运用可以帮助我们实现导出Word文档的功能。今天我们将为大家介绍PHP处理Word转PDF的相关实现方法。

  PHP处理Word转PDF代码示例:

PHP代码
  1. <?php       
  2. set_time_limit(0);       
  3. function MakePropertyValue($name,$value,$osm){       
  4. $oStruct = $osm->Bridge_GetStruct       
  5. ("com.sun.star.beans.PropertyValue");       
  6. $oStruct->Name = $name;       
  7. $oStruct->Value = $value;       
  8. return $oStruct;       
  9. }       
  10. function word2pdf($doc_url$output_url){       
  11. $osm = new COM("com.sun.star.ServiceManager")       
  12. or die ("Please be sure that OpenOffice.org     
  13. is installed.
    "
    );       
  14. $args = array(MakePropertyValue("Hidden",true,$osm));       
  15. $oDesktop = $osm->createInstance("com.sun.star     
  16. .frame.Desktop");       
  17. $oWriterDoc = $oDesktop->loadComponentFromURL       
  18. ($doc_url,"_blank", 0, $args);       
  19. $export_args = array(MakePropertyValue       
  20. ("FilterName","writer_pdf_Export",$osm));       
  21. $oWriterDoc->storeToURL($output_url,$export_args);       
  22. $oWriterDoc->close(true);       
  23. }       
  24. $output_dir = "D:/LightTPD/htdocs/";       
  25. $doc_file = "D:/LightTPD/htdocs/2.doc";       
  26. $pdf_file = "2.pdf";       
  27. $output_file = $output_dir . $pdf_file;       
  28. $doc_file = "file:///" . $doc_file;       
  29. $output_file = "file:///" . $output_file;       
  30. word2pdf($doc_file,$output_file);       
  31. ?>  

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

Time limit is exhausted. Please reload CAPTCHA.