CentOS 下安裝 OpenOffice4.0


一、更新服務器

yum源

[root@APP2 /]# yum clean all 

[root@APP2 /]# yum makecache 

[root@APP2 /]# yum update

1、首先先下載好需要的rpm包:Apache_OpenOffice_4.0.0_Linux_x86-64_install-rpm_zh-CN.tar.gz

或直接命令下載:wget http://heanet.dl.sourceforge.net/project/openofficeorg.mirror/4.0.0/binaries/zh-CN/Apache_OpenOffice_4.0.0_Linux_x86-64_install-rpm_zh-CN.tar.gz

放到服務器的目錄下(我放到了opt下)

刪除之前安裝的OpenOffice 

[root@APP2 opt]# yum remove openoffice* libreoffice*

2、將下載的openoffice解壓(我直接解壓到opt目錄):tar -zxvf Apache_OpenOffice_4.0.0_Linux_x86-64_install-rpm_zh-CN.tar.gz

3、解壓后生成文件夾zh-CN 進到RPMS目錄下,直接yum localinstall *.rpm

4、進入到desktop-integration目錄,選擇安裝相關的套件,我選擇的是redhat

rpm -ivh openoffice4.1.1-redhat-menus-4.1.1-9775.noarch.rpm

5、安裝完成直接啟動Openoffice服務:

進入opt下的openofiice4目錄:cd /opt/openoffice4
進入program目錄
執行 soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard & 
完成啟動

臨時啟動   /opt/openoffice4/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
一直后台啟動 nohup  /opt/openoffice4/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

windows啟動命令:soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

windows啟動命令里面短連接號后面不帶空格“ -nofirststartwizard ”
        linux啟動命令:soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &

6、查看服務是否啟動(端口8100是否被soffice占用):netstat -lnp |grep 8100

顯示結果:tcp        0      0 127.0.0.1:8100              0.0.0.0:*                   LISTEN      19501/soffice.bin

7.-安裝遇到的問題和解決------原則是缺什么補什么包

1、/opt/openoffice4/program/soffice.bin: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory

https://pkgs.org/download/libXext.so.6()(64bit)

安裝  libXext rpm 或者yum install libXext.i686

 

如果出現這種情況,說明在/opt/openoffice4/program/下缺少libXext.so.6文件,可以去/usr/lib64 或者 /usr/lib 查看有沒有這個文件,如果有就copy到/opt/openoffice4/program/目錄里面,如果沒有在安裝

# yum install libXext.x86_64

2、 /opt/openoffice4/program/soffice.bin: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory

找不到libfreetype.so.6文件,同上輸入:yum install libfreetype.i686,安裝完之后去那兩個目錄找libXext.so.6復制到/opt/openoffice4/program/目錄里面,賦予權限。

3、報問題:no suitable windowing system found, exiting.
輸入安裝:yum groupinstall "X Window System" ,一路安裝完之后重啟系統,在啟動openoffice服務看看。

 4、出現中文亂碼

4.1、先從你本機 C:\Windows\Fonts 拷貝或者網絡上下載你想要安裝的字體文件(*.ttf文件)到 /usr/share/fonts/chinese/TrueType 目錄下(如果系統中沒有此目錄,則自行mkdir創建,亦可重命名為自己喜歡的文件夾名)

4.2、修改字體文件的權限,使root用戶以外的用戶也可以使用

# cd /usr/share/fonts/chinese/TrueType
# chmod 755 *.ttf

4.3、建立字體緩存

# mkfontscale (如果提示 mkfontscale: command not found,需自行安裝 # yum install mkfontscale )
# mkfontdir 
# fc-cache -fv (如果提示 fc-cache: command not found,則需要安裝# yum install fontconfig )

4.4、重啟計算機

 

8.java調用openOffice服務

1.下載JodConverter http://download.csdn.net/detail/kerryzb/9529876

2.java調用

package com.kerryzb.util;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.ConnectException;

import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;

public class OfficeToPDF {

/**
* 將Office文檔轉換為PDF. 運行該函數需要用到OpenOffice, OpenOffice下載地址為
* http://www.openoffice.org/
*
* <pre>
* 方法示例:
* String sourcePath = "F:\\office\\source.doc";
* String destFile = "F:\\pdf\\dest.pdf";
* Converter.office2PDF(sourcePath, destFile);
* </pre>
*
* @param sourceFile
* 源文件, 絕對路徑. 可以是Office2003-2007全部格式的文檔, Office2010的沒測試. 包括.doc,
* .docx, .xls, .xlsx, .ppt, .pptx等. 示例: F:\\office\\source.doc
* @param destFile
* 目標文件. 絕對路徑. 示例: F:\\pdf\\dest.pdf
* @return 操作成功與否的提示信息. 如果返回 -1, 表示找不到源文件, 或url.properties配置錯誤; 如果返回 0,
* 則表示操作成功; 返回1, 則表示轉換失敗
*/
public static int office2PDF(String sourceFile, String destFile) throws FileNotFoundException {
try {
File inputFile = new File(sourceFile);
if (!inputFile.exists()) {
return -1;// 找不到源文件, 則返回-1
}

// 如果目標路徑不存在, 則新建該路徑
File outputFile = new File(destFile);
if (!outputFile.getParentFile().exists()) {
outputFile.getParentFile().mkdirs();
}

// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(
"127.0.0.1", 8100);
connection.connect();

// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(
connection);
converter.convert(inputFile, outputFile);

// close the connection
connection.disconnect();

return 0;
} catch (ConnectException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

return 1;
}

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM