4

I would like to use OO/LO PDF generation capabilities in my applications. To do it, I need to be able to modify a previously generated odt template from my code. The modification would be simple text replacements only (which do not even require regexes).

OO's developer's guide does not contain any examples or tutorials which would allow me to do what I need to do.

Neither is LO's developer's guide useful. It contains multiple java examples, but no useful C++ code.

For both APIs a doxygen documentation is available - but there is no general introduction and browsing the entire code base and reverse engineering the classes and discovering how to use them is too tedious and cumbersome.

To sum up: how can I modify odt files using a C or C++ API?

Dariusz
  • 21,561
  • 9
  • 74
  • 114
  • Did you look at the [examples](http://api.libreoffice.org/examples/examples.html)? – devnull Jan 10 '14 at 08:45
  • 1
    @devnull did you? Yes, I did my research and explored the whole guide - both guides actually. There are examples for C++, though their usefulness to me is nearly zero. – Dariusz Jan 10 '14 at 08:47
  • A ODT document is nothing but a ZIP file with mainly XML files in it. Unpack, edit the XML, repack, and you are done. – Bart Friederichs Jan 10 '14 at 08:49
  • @BartFriederichs I have thought of this and am considering it, though I would prefer to do it the proper and official way. It is possible that the text, internally, will be somehow distorted by some xml tags, or the format will change and my code becomes invalid... I'd like to avoid it. – Dariusz Jan 10 '14 at 08:53

2 Answers2

2

I ended up extracting the archive, processing and editing xml, then packing it back up again.

Worked well.

Dariusz
  • 21,561
  • 9
  • 74
  • 114
0

Qt has ODT file handler by default

http://doc.qt.io/qt-5/qtextdocumentwriter.html

Chnossos
  • 9,971
  • 4
  • 28
  • 40
Captain Barbossa
  • 1,067
  • 10
  • 16