Home Home > 2010 > 02 > 21 > Kraft Document Templating System
Sign up | Login

Kraft Document Templating System

February 21st, 2010 by

One of the most important objectives for Kraft is to create business documents of perfect quality. The docs are an important face to the customer and represent the business, so best is just good enough. The old times where invoices got printed on a 24 needle printer in ascii mode should finally be gone ;-)

Documents should represent the ‘coorperate identity’, which in small size firms probably comes down to printed stationary with a company logo and some other information on it. Kraft has to print  nicely on it. For that it is important that the layout can be configured at all and without compiling Kraft if the customer address should be printed fife millimeters higher for example.

Currently Kraft uses a document template written in RML for the layout. RML is a XML format which can be converted to PDF utilizing a python based command line tool which is called by Kraft. RML is a open source toolkit, quite powerful and mature. However, it does not solve all problems with flexible document creation and sometimes comes a bit unhandy. As a result our eyes are always open for alternatives.

Here are some requirements a template system must provide:

  • There is a document template in the file system. It can be changed by the user without recompiling Kraft. Kraft picks it up, fills the document values in and processes it to PDF. Other output formats are optional.
  • Layout: Areas where parts of the document are printed can be freely specified, ie. where the address, the date etc. is printed.
  • Graphical elements like lines, fixed text, boxes, colors and images can be placed everywhere.
  • The system knows at least different layouts for the first page, middle pages and the last page.
  • All pages have page header and footer.
  • Loops: Since an invoice for example has an unknown amount of items the system must be able to handle that, including clever space management with  pagebreaks. Nested loops are possible.
  • Maintain areas which must not be split, i.e. an invoice item should be printed completely on one page and not be split by a pagebreak.
  • Text faces, paragraph alignment, width, spacing and these kind of things must be configurable in the template.
  • Some variables are available such as a page counter.
  • Really great would be if the system provides carryover of calculations, like  on the top and bottom of each page the so far accumulated sum is printed.

Which free layouting and PDF generating system is able to provide that, preferably Qt/KDE based? Kugar was striving to solve it but when I tested it it did not work out.

Another idea is to use the ability of KWord to work with templates. If Kraft could read KWord templates, fill them and automatically generate a KWord doc from it, that would be a great solution, because in addition to automatic PDF generation documents could easily be exported as KWord docs and changed manually if needed. A great ‘template editor’ also would be available. This would in the direction of office suit integration that commercial Kraft competitors nowadays have.

I am not sure how far we are away from that. Something to investigate.

Both comments and pings are currently closed.

6 Responses to “Kraft Document Templating System”

  1. jstaniek

    Klaas,
    Kugar successor, Kexi’s Report Designer and Renderer, is coming in KOffice 2.2. Interestingly, it’s a fork (read: cleanup) of OpenRPT. Exports to HTML and paints using QPainter so also on QPrinter. For more info, ask on koffice-devel at kde.org.
    The idea with using KWord is also out TODO, it’s about generating different types of documents in a bit different way.

    For news about the development, read http://www.piggz.co.uk/index.php?page=allnews

    PS: Now we have ODF-like open format developed… http://wiki.koffice.org/index.php?title=Kexi/Plugins/Reports/Fileformat

  2. Grantlee is intended for that kind of use. I intend to use it in KJots and other areas of KDE PIM. I’m having some cmake trouble with it at the moment, but when that’s solved it will get a 0.1 release.

    http://www.gitorious.org/grantlee/pages/Home

  3. Thomas Richard

    Hm, I didn’t really have the time to look thoroughly at Kexi’s report designer and Grantlee but what would be the big difference between these two?

  4. So from my reading of the kraft webpages I understand that this is a bit of a database-publishing workflow. The actual user interface for entering information was not in the screenshots at least.

    This is something that KOffice intends to make possible. At least its a usecase that I have had in the back of my mind for a while now.

    Creating templates is indeed something you can do in KWord. This includes the placement of things like logos, address-boxes, footers etc etc.
    The missing piece right now is easy support to take that template and match it with external content. We have some (python) scripts that do this in a basic manner already but you might find that a bit simplistic. The scripting API needs a lot of love ;)

    I’m a bit unsure what your ideal workflow is. Where does the user type his content? Is there any WYSIWYG editor involved? What happens when the text has just one line on page 2? The answers to those questions are likely going to be very different based on what technology you use. Making this workflow happen *inside* of KWord by means of plugins can give you a lot of power and flexibility.

    Feel free to ping me on IRC or give me a call if you are interested in more details!

    Thomas (KWord maintainer)

  5. Hi Klaas,

    I think you should probably look at ODF-XSLT. Although it is written in PHP5, I think the solution it provides is very much what you need (even if you may have to port it) – a document generator library that brings the full power of XSLT to OpenDocument files. It enables you to use ODF files as if they were plain XSLT templates. It also includes a few extra parsing options that allow you to edit the XSLT parts of these ODF from within your favourite office suite. ODF-XSLT is developed by Sander Marechal, the lead developer of Officeshots.org, and is released as Free Software under the GNU General Public License, version 3:

    http://www.jejik.com/odf-xslt

    Best,
    Michiel

  6. Klaas Freitag

    Thanks all for the very interesting input. It’s very much, over time we will dig deeper into that topic and maybe contact you for details. Thanks for your help!