2014-10-27 62 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