{"id":28,"date":"2014-11-28T01:35:56","date_gmt":"2014-11-28T01:35:56","guid":{"rendered":"http:\/\/privateblog.nobytesleft.net\/?p=28"},"modified":"2014-11-28T01:35:56","modified_gmt":"2014-11-28T01:35:56","slug":"generating-an-odf-document-in-php","status":"publish","type":"post","link":"https:\/\/privateblog.nobytesleft.net\/?p=28","title":{"rendered":"Generating an ODF document in PHP"},"content":{"rendered":"<p>Sometimes, you have to generate some kind of document, a commercial offer for example, based on some data that has been\u00a0entered into some HTML form, and you want it to remain editable, so a PDF document is not the\u00a0solution. You may consider generating an HTML document, but you quickly realize that you want\u00a0something that is easily editable by your HTML-illitterate co-worker. Using\u00a0<a href=\"http:\/\/en.wikipedia.org\/wiki\/OpenDocument\" target=\"_blank\">OpenDocument<\/a>\u00a0would be an excellent choice.<\/p>\n<p>Since you\u00a0know that an ODF\u00a0file is &#8220;just zipped xml&#8221;, you may think that creating the\u00a0file from scratch is the way to go. A\u00a0better way, if the document has any complexity in it, is to start from some template, and with a few instructions change it into your final document.<\/p>\n<p>A quick search reveals a few tools that can be used in this way. The one is suiting me best now is OpenTBS, which is a plugin for\u00a0the &#8220;<a href=\"http:\/\/www.tinybutstrong.com\/plugins\/opentbs\/demo\/demo.html\" target=\"_blank\">TinyButStrong<\/a>&#8221; PHP template engine. It seems\u00a0easy to use: You\u00a0set a few &#8220;anchors&#8221; in your template, a few variables in your PHP code, and it works.\u00a0It is flexible enough that you can change values in the formulae inside table cells, add rows to tables, link pictures and so on. The TBS template engine is just one PHP file, and OpenTBS another PHP file. It can&#8217;t really get any simpler than this.<\/p>\n<p>As a side note, I wonder if there is any WordPress plugin to export blog entries as an ODF document. Could it be useful to convert an entire blog to a still-editable book?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, you have to generate some kind of document, a commercial offer for example, based on some data that has been\u00a0entered into some HTML form, and you want it to&hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-28","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/28","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=28"}],"version-history":[{"count":2,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions"}],"predecessor-version":[{"id":30,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=\/wp\/v2\/posts\/28\/revisions\/30"}],"wp:attachment":[{"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=28"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=28"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/privateblog.nobytesleft.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=28"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}