2014-10-27 83 views
1

我需要一個HTML2RTF工具,即將HTML格式轉換爲RTF格式的軟件......但不是「任何轉換」:我需要保留HTML class屬性(例如段落)作爲MS-Word「樣式」。HTML-to-RTF文檔轉換,將類保存爲樣式

我的第一選擇是LibreOffice中的一些終端的命令,比如

libreoffice --convert-to 

因爲LibreWriter具有更大的社會和假設最好的軟件皈依......但失望,因爲沒有保護類屬性的風格,即使測試作爲圖形界面中的用戶。

我需要一個Linux解決方案(還有abiword沒有解決)...或者,最後一個選項,一個web服務,以方便插入intranet的Windows服務器。


輸入樣本:

<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>sample1 doc</title> 
    <!-- no style need, but can be declarated with anything, don't matter --> 
    <style type="text/css"> 
    .myStyle1 {color: #F00;} .myStyle2 {color: #880;} 
    .a {color: #00F;} .b {color: #088;} 
    </style> 
</head> 
<body><!-- important to preserve class names --> 
    <p class="myStyle1">Hello in <i>style#1</i>. 
    <span class="a">SPAN S1</span>.</p> 
    <p class="myStyle2">... Hello in style#2...</p> 
    <p class="myStyle1">Bye <span class="b">S2</span>.</p> 
</body> 
</html> 

在MS-Word中該樣品進口看起來不錯,與風格在哪裏班。 在LibreOffice(和libreoffice終端工具)中沒有。

那麼,LibreOffice還有另外一個工具嗎?有一個Linux的工具?

PS:最後的可能性,如果沒有Linux的,webservice Windows和MS-Office。

回答

1

適用於Libreoffice 4.3.3.2。剛剛打開了您提供的HTML文件,我可以看到名爲Text.Body.myStyle1和myStyle2的樣式。

HTML styles in Libreoffice


線索,爲Debian穩定和Ubuntu LTS 64位...查看this How-To。基本步驟:

sudo apt-get remove libreoffice* 
wget http://download.documentfoundation.org/libreoffice/stable/4.3.3/deb/x86_64/LibreOffice_4.3.3_Linux_x86-64_deb.tar.gz 
tar -xzvf LibreOffice_4.3.3_Linux_x86-64_deb.tar.gz 
cd LibreOffice_4.3.3*_Linux_x86-64_deb/DEBS 
sudo dpkg -i *.deb 

V4.3.3之後,也需要安裝:

sudo apt-get install libreoffice-writer 

然後,引用命令:

libreoffice --headless -convert-to rtf libreTeste.html 
+0

嗚嗚......是的,有一個版本的問題,4.3.3正常工作! – 2014-11-21 18:02:30