Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Generate open document from template



  • Hello

    I would like to generate a new document from an ODT template. To do so, placeholders would have to be filled out.
    Is there perhaps a class that I can use or do I have to write everything myself?

    I find heaps of classes for Java or PHP. If it knows who, tinybutstrong is a PHP class that would do just that. However, an ODT document with tables is enough.

    Does anyone know what?

    Thanks Chris



  • Open Documents are nothing more than zip files with xml and images in them (not sure on images). So if you have an ODT you can get the text out of it just by unzipping it and searching through the xml files. There is probably a spec for them somewhere. Maybe even code snippets.

    They are not complicated documents. I agree that a library is easier sometimes. I used Python to create a bunch of ODS files a while back. Let us know if you find a nice C++ lib. Or if you write a nice lib...

    One possibility is you could use WebEngine to run the PHP code to create documents. Heavy handed, yes, but doable.



  • Thank you. That it is a zip file was clear to me. I hope that I find such a class. If not I have nothing else to write about myself.

    No, the PHP class was just one example ;-) But the class has a lot of unnecessary code. A port would be too much effort. I can do it myself better.

    lg Chris


  • Lifetime Qt Champion

    Hi,

    I think you might be interested by QTextDocumentWriter.

    Sorry, I misread ODT for ODF.


Log in to reply