Glom Precise Printouts

At some time I’ll have to implement a type of printout or report in Glom that uses fixed positioning. For instance, to enter text into the correct spaces on pre-printed forms, or just so that printouts always look the same. At the moment, printouts take up as much space as necessary, and flow appropriately (I “print out” to HTML in the browser at the moment).

So, suggestions are welcome for some code that I should reuse, or adapt. I guess it would need the following abilities.

  • Specify text areas precisely, such as specifying the position and size.
  • Optionally specify the position in terms of alignment, so that text areas slide left or right.
  • Flowing text into those areas, and simply truncating the text if it’s too big. (Or maybe making the font size smaller.)
  • Text justification inside the text areas.
  • Specifying page margins.
  • Coping with a changing page size (e.g. A4 versus Letter) by increasing/cutting-off margins.
  • Have a nice GTK+-based UI for doing this.

Something using cairo and pango would be nice.

4 thoughts on “Glom Precise Printouts

  1. For your printing problem, there is a quick and dirty hack which happens to be ISO approved. Use a paper format which is 21cm by 11″ … Basically, this paper format will fit inside both A4 and US Letter papers. A4 prints will look akward because of high margins at the top and the bottom and Letter prints will also look akward because of wide margins on the sides.

    Either way it’ll print just fine and it means more time for you to spend on actual printing instead of trying to figure out paper margins from the printer … :)

    Rémi

  2. “Flowing text into those areas, and simply truncating the text if it’s too big. (Or maybe making the font size smaller.)”

    With regards to this, thinking about the filemaker-based database I use all the time, I would love it if you could set up a maximum textbox size + a standard font-size + a minimum font-size. When you enter the original field, glom would then warn you if you were typing more than would print out. Font-size adjustments (down to the minimum size) would happen automatically.

    I’m very excited, btw, to see pygtk scripting… if this became cross-platform (i.e. Windows & Mac) some day, I could potentially convert my school from the filemaker nightmare we live with today for student data to something glom-based (I think this is more the fault of the designer we paid than of filemaker itself, but since filemaker’s not free software, I’m not willing to fiddle around with our system to improve it).

  3. It seems that any spreadsheet application would need to solve these same problems. Would Gnumeric code meet your requirements?

    I would caution against either “simply truncating” or altering the font size. The first option, while usually fine for text where the effect is noticable, could silently drop digits. I’m pressed to think of an occasion where a printed report might have insignificant digits. The other option, altering the font size, could render a table of numbers in a rather difficult to read manner.

    Alignment on a decimal point might be useful, too.

    Cool app.

  4. I think Inkscape implements this on top of SVG – it has all functionality you mentioned and has perfect GUI for preparing templates too – in my opinion. It’s multi-platform and have possibility to convert SVG into Postscript for print even on command line.

    For putting inside final data you can specify inside of text object using Inkscape something like “$table.variable” or similar (‘$’ is quite nice, because it’s not used in XML anywhere, so it’s nice to replace in saved document).
    For dividing of repeating parts (like head, foot, lines, etc) we can add some attributes to Horizontal Guideline (eg. tag).
    In the beginning Inkscape built-in XML Editor (Shift-Ctrl-X) can be used during preparing of templates, later special Template plug-in for inkscape can be prepared…

    The only thing what needs to be implemented right now is program which do the generation of new SVG (or more of them – each page one, Inkscape doesn’t implement multipage SVG) – with repeated parts (in templates divided by guidelines) and with replaced $variable in XML by live data from Glom.

    I did something similar for generating Excel sheets from templates using Gnumeric (and it’s ssconvert) by python and cheetah-templates. Maybe that can be used for Glom too… Abiword exports can be done the same way.
    I think this functionality is even stronger than FileMaker have for export right now.

    BTW There is Kugar designer, part of KOffice which implements Reports Designer with GUI and GUI-independent filler for XML-based data and template – maybe inspiration?. There is something similar to Glom in KDE too – KExi – http://www.kexi-project.org/.

    I’m really interested in Glom, I would like to participate later (after my thesis is done). Feel free to contact me by email if I can help you some way…

Comments are closed.