Offline library for rendering OpenOffice formula?

Is there a stand-alone library for rendering OpenOffice formulas ? I am looking for something that can take plain text (e.g. E = mc^2 ) in the same syntax used by OpenOffice and convert it to png or pdf snippets.

(note: I don't need a WYSIWYG editor, just a visualization tool. Basically, I would like to work in OpenOffice to interactively edit my formulas, and then copy the source code for use in other contexts without having to use OpenOffice to make them.)

+4
source share
2 answers

I use unoconv to convert an OpenOffice / LibreOffice document to PDF.

However, at first I had to create some input document with the formula. Unfortunately, it is not possible to use the formula editor to create an ODF file because the output PDF file will contain strange headers and footers.

So I created a simple text document (in Writer) and entered the formula as a single object (aligned as a character). I saved the ODT file, unzipped it (since ODT is just a ZIP) and edited the content. Then I determined which files to delete and format the remaining files to get a minimal example.

In my example, the formula itself is in Formula/content.xml . Simple code changes in the <annotation>...</annotation> tags can be easily automated.

Finally, I pinned the directory and created a new ODT file. Then, using unoconv and pdfcrop , I created a good PDF formula.

enter image description here

 # this trick prevents zip from creating an additional directory cd formula.odt.unzipped zip -r ../formula.odt . cd .. unoconv -f pdf formula.odt # ODT to PDF pdfcrop formula.pdf # keep only the formula # you can convert the PDF to bitmap as follows convert -density 300x300 formula-crop.pdf formula.png 

The contents of the unpacked ODT directory:

The following is the minimum contents of the ODT formula.odt file.

 formula.odt.unzipped/Formula/content.xml formula.odt.unzipped/META-INF/manifest.xml formula.odt.unzipped/content.xml 

The formula.odt.unzipped/Formula/content.xml file contains:

 <?xml version="1.0" encoding="UTF-8"?> <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"> <semantics> <annotation encoding="StarMath 5.0"> f ( x ) = sum from { { i = 0 } } to { infinity } { {f^{(i)}(0)} over {i!} x^i} </annotation> </semantics> </math> 

The formula.odt.unzipped/content.xml file contains:

 <?xml version="1.0" encoding="UTF-8"?> <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink"> <office:body> <office:text> <text:p> <draw:frame> <draw:object xlink:href="./Formula"/> </draw:frame> </text:p> </office:text> </office:body> </office:document-content> 

The formula.odt.unzipped/META-INF/manifest.xml file contains:

 <?xml version="1.0" encoding="UTF-8"?> <manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"> <manifest:file-entry manifest:full-path="/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.text"/> <manifest:file-entry manifest:full-path="content.xml" manifest:media-type="text/xml"/> <manifest:file-entry manifest:full-path="Formula/content.xml" manifest:media-type="text/xml"/> <manifest:file-entry manifest:full-path="Formula/" manifest:version="1.2" manifest:media-type="application/vnd.oasis.opendocument.formula"/> </manifest:manifest> 
+2
source

There are several web services that launch LaTeX for you and return the image. For example, http://rogercortesi.com/eqn/

0
source

All Articles