Libre / Open和writer2Latex,来自Python的调用

时间:2012-12-21 21:16:00

标签: python latex openoffice.org libreoffice

我遇到了Open / Libre Office的这个精彩扩展,writer2Latex,它可以将我的整个文档转换为TeX格式。它工作得很好所以我想知道是否有可能跳过open / libre office应用程序并直接调用writer2Latex蟒蛇?我希望我的python应用程序只使用word文档作为输入调用writer2Latex,并获取生成的latex文件。

1 个答案:

答案 0 :(得分:0)

这应该可以使用Python + uno。该方法与导出为PDF非常相似,这对于人们来说比导出到TeX / Latex更常见。 LibreOffice / OpenOffice有一组可以改变的导出过滤器。

有关使用Python + LibreOffice / OpenOffice的一些常规文档,请参阅DocumentHacker.com,例如如何打开文档。您需要修改的食谱中的配方是“转换为PDF”。只需使用乳胶过滤器名称

替换输出过滤器
#already have the document open
from com.sun.star.beans import PropertyValue
outputfiltername = "writer_pdf_Export" #for PDF
property = (
    PropertyValue( "FilterName" , 0, outputfiltername , 0 ),
)
document.storeToURL("file:///home/my_username/output.pdf", property)

我不确定FilterName应该是什么,也许你可以从writer3Latex文档中解决它。我发现一个PDF表明应该是:

outputfiltername = "org.openoffice.da.writer2latex"

但我没有测试过它(搜索“FilterName”)。