Print yourself!

I’ve been working a bit on a printing API for gtk+. Its a highlevel API that integrates cairo, pango and a native print dialogs. Its really easy to get nice printing output, and it will work on all platforms, using native printing. I just made a code drop so that people can look at the APIs and comment on it.

The example code in it is pretty awesome, it actually prints itself. Here is the output pdf.

If you read that pdf you’ll see it produces some other output too. I’m sure interested parties can find that file too. 🙂

11 thoughts on “Print yourself!”

  1. It looks like the text is converted to a raster image. It could be from the printfile > pdf creation step (actually, I hope it is)…

  2. Is there any documentation, or should we just look at the code? Can you provide some some practical examples of how this will make printing better?

    Keep up the good work
    Petar

  3. Petar wrote:
    > how this will make printing better?

    This API will allow you to use the same Cairo based drawing code for rendering your document with your application as for printing it, sending it via mail, whatever – and if this should not be advantage enough: This API will support you on printer detection, paper setup and pagination. Well and it will be platform independent. Guess that should be sufficient advantage over handcrafted Postscript to lp piping, shouldn’t it?

  4. tbf, I wasn’t tying to be unpleasant, I’m not a developer and I just needed clarification. Thanks for the info!
    I’m glad that people are thinking about printing, I’ve felt it was forgoten for for some time…

  5. @Petar: Sorry for being harsh. My work is quite unpleasant today, should try harder to find a job where I can work with the GNOME platform. :-/

  6. Alexander, my only concert having looked at the C API is that it looks like we have to use a different pango layout constructor function egg_print_context_create_layout(EggPrintContext *context) rather than pango_cairo_create_layout (cairo_t *cr) which we normally use when using pango with cairo.

    Doesn’t this mean that we’d have to use different code to print to a pdf than to print to draw to the screen? I thought that was one of the main advantages of using cairo for Gtk+, that we could share our drawing and printing code.

    Am I misunderstanding?

  7. Duncan: pango_cairo_create_layout() is a convenience function that creates a PangoLayout for screen use. It sets the DPI based on display settings (i.e. almost always 96 dpi), not what the actual printer target DPI. If you use a layout from pango_cairo_create_layout() on a non-display target you’ll get the wrong results.

    This is slightly unfortunate, but there is not much to do about it.

Comments are closed.