1

我在将 OMML(开放式办公室中的数学 XML)转换为图像时遇到了问题。

这个功能在我正在进行的项目中,应该部署在 Linux 上。为了效率,我应该选择没有MS产品的方法(如dll、MS Office扩展等)。

显示一些发现:

  1. OMML 可以转换为 MATHML(通过 XSLT),然后我可以将 MATHML 转换为图像(通过 jeuclid)。
  2. OMML 可以转换为 LaTex(通过 XSLT 或 writer2tex),然后我可以将 LaTex 转换为图像(通过 mediawiki 的 texvc)。

但是,所有这些解决方案都依赖于第 3 软件或 XSLT。有没有更好的方法来进行这种转换?

4

2 回答 2

0

例如,我只需编写一个宏,将 OMML 导入 OOo/AOO/LibreOffice 绘图并将其导出为 png。

网上有很多关于如何使用带有过滤器的 OpenOffice 宏的示例。

您可以从命令行运行 openoffice 宏。

像这样的东西,我没有时间研究更多,对不起......

Sub Macro1(outfile, formula)
   ' Create a drawing.
   oDoc = StarDesktop.loadComponentFromURL( "private:factory/sdraw", "_blank", 0, Array() )
   ' Get the first page.
   oDrawPage = oDoc.getDrawPages().getByIndex( 0 ) 
   ' Input and output files - to be converted to URL's
     iURL = ConvertToURL(formula)
     oURL = ConvertToURL(outfile)
   ' Get a position in the drawing (not sure this works in draw, it does in writer)
   set oViewCursor = objDocument.CurrentController.getViewCursor()
   set oTextCursor = objDocument.Text.createTextCursorByRange(oViewCursor.getStart())
   'insert formula
   oTextCursor.InsertDocumentFromURL iFile, Array() 
      ' Save the document using a filter.
   oDoc.storeToURL(oURL, Array(MakePropertyValue("FilterName", "draw_png_Export"), ))
End Sub

要从命令行运行它,请使用以下命令:

sdraw -invisible "macro:///Standard.Module1.ConvertWordToPDF('c:\formula.odf', 'c:\image.png')"

问候,

生命值

于 2013-06-28T10:48:24.237 回答
0

这是我找到的最简单的解决方案,使用 libreoffice 的 headless 选项:
1. 找到您的 doc 文件所在的文件夹(即 test.doc)
2. 如果 Libreoffice 正在运行,请关闭它。否则下面的命令什么都不做。
3.运行以下命令(debian和libreoffice 3.5,其他操作系统和版本可能不同)

libreoffice --headless --convert-to html --outdir out test.doc

  1. 探索 out 目录,您将找到带有 base64 图像的 html 文档。
  2. 制作您自己的脚本来自动执行前面的步骤。
于 2015-02-16T10:04:48.547 回答