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.

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>
source share