关于WORLD转PDF


1. 需要用的软件

    OpenOffice 下载地址http://www.openoffice.org/

    JodConverter 下载地址http://sourceforge.net/projects/jodconverter/files/JODConverter/

2.启动OpenOffice的服务

安装完openoffice,安装服务

启动 cmd 运行

cd C:\Program Files (x86)\OpenOffice4\program

执行

soffice -headless-accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

查看是否安装成功,查看端口对应的pid

    netstat -ano|findstr"8100"

 查看pid对应的服务程序名

    tasklist|findstr "pid值"

3.将JODConverter的Jar档放进专案中的Library

 请检查你的专案是否包含以下的Jar档:

  jodconverter-2.2.1.jar

  jurt-2.3.0.jar

  xstream-1.2.2.jar

  ridl-2.3.0.jar

  commons-io-1.3.1.jar

  juh-2.3.0.jar

  slf4j-api-1.4.3.jar

  unoil-2.3.0.jar

slf4j-jdk14-1.4.3.jar

4. 下面是实现代码

附件里面有现成的可以用的项目示例,直接导入eclipse就可以运行

1.  /** 

2.       * Office文档转换为PDF. 运行该函数需要用到OpenOffice, OpenOffice下载地址为 

3.       * http://www.openoffice.org/ 

4.       *  

5.       * <pre> 

6.       * 方法示例: 

7.       * String sourcePath = "F:\\office\\source.doc"; 

8.       * String destFile = "F:\\pdf\\dest.pdf"; 

9.       * Converter.office2PDF(sourcePath, destFile); 

10.      * </pre> 

11.      *  

12.      * @param sourceFile 

13.      *            源文件绝对路径可以是Office2003-2007全部格式的文档, Office2010的没测试包括.doc, 

14.      *            .docx, .xls, .xlsx, .ppt, .pptx示例: F:\\office\\source.doc 

15.      * @param destFile 

16.      *            目标文件绝对路径示例: F:\\pdf\\dest.pdf 

17.      * @return 操作成功与否的提示信息如果返回 -1, 表示找不到源文件url.properties配置错误如果返回 0, 

18.      *         则表示操作成功返回1, 则表示转换失败 

19.      */  

20.     public static int office2PDF(String sourceFile, String destFile) {  

21.          OpenOfficeConnection connection =null;

22.         try {  

23.             File inputFile = new File(sourceFile);  

24.             if (!inputFile.exists()) {  

25.                 return -1;// 找不到源文件则返回-1  

26.             }  

27.   

28.             // 如果目标路径不存在则新建该路径  

29.             File outputFile = new File(destFile);  

30.             if (!outputFile.getParentFile().exists()) {  

31.                 outputFile.getParentFile().mkdirs();  

32.             }  

33.               

34.             // connect to an OpenOffice.org instance running on port 8100  

35.             connection = new SocketOpenOfficeConnection(  

36.                     "127.0.0.1"8100);  

37.             connection.connect();  

38.   

39.             // convert  

40.             DocumentConverter converter = new OpenOfficeDocumentConverter(  

41.                     connection);  

42.             converter.convert(inputFile, outputFile);  

43.   

44.             // close the connection  

45.   

46.             return 0;  

47.         } catch (ConnectException e) {  

48.             e.printStackTrace();  

49.         } finally {

50.                 try{

51.                         if(connection!= null){

52.                                 connection.disconnet();

53.                                 Connection= null;

54.                         }

55.                 }catch(Exceptione){

56.                         

57.                 }

58.          }

59.  

60.   

61.         return 1;  

62.     }  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
PowerWorld是一种用于电力系统建模和分析的电力系统软件。其中,PowerWorld PDF是PowerWorld软件的一部分,它是PowerWorld公司提供的电力系统应用手册的电子版本。 PowerWorld PDF提供了丰富的资源,帮助用户更好地理解和使用PowerWorld软件。它包括软件的详细说明、操作指南和具体示例等。通过PowerWorld PDF,用户可以了解PowerWorld软件的各种功能、工具和技术,以便更好地进行电力系统的建模、仿真和分析。 PowerWorld软件以其强大的功能和易用性而闻名,广泛应用于电力行业。它可以对电力系统进行各种建模和仿真,包括潮流分析、稳态和暂态稳定性分析、潮流优化、短路分析等。同时,PowerWorld软件还提供了可视化的界面,让用户可以直观地了解电力系统的运行状况、故障等。 PowerWorld PDF的存在使用户能够更加全面地学习和使用PowerWorld软件。无论是初学者还是有经验的电力系统工程师,都可以通过PowerWorld PDF了解如何使用PowerWorld软件进行电力系统分析和研究。它是一个非常有用的参考资料,帮助用户解决各种与电力系统相关的问题。 总之,PowerWorld PDF是一种电力系统应用手册的电子版本,为用户提供了对PowerWorld软件的详细说明和操作指南。通过PowerWorld PDF,用户可以更好地理解和使用PowerWorld软件,进行电力系统建模和分析。这对于电力行业的专业人士和学习者来说是非常有益的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值