我偶然发现了Open/Libre Office的一个很棒的扩展,writer2Latex,它可以将我的整个文档转换成TeX格式。它工作得很好,所以我想知道是否可以跳过打开/libre office应用程序,直接从writer2Latex调用Python.我希望我的python应用程序只调用writer2Latex,将word文档作为输入,并获得生成的latex文件。
发布于 2013-03-06 05:43:53
使用Python + uno可以做到这一点。这种方法非常类似于导出到PDF,这是人们更常见的做法,而不是导出到TeX / Latex。LibreOffice / OpenOffice有一组可以更改的导出过滤器。
有关使用DocumentHacker.com + LibreOffice / OpenOffice的一些一般文档,例如如何打开文档,请参阅Python。食谱中你需要修改的食谱是“转换为PDF”。只需将输出过滤器替换为latex过滤器名称
#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")。
https://stackoverflow.com/questions/13997286
复制相似问题