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 Responses to “Print yourself!”

  1. Ross says:

    The text in the PDF isn’t sharp at all, it’s very blury. Is that a known issue?

  2. Danny says:

    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)…

  3. Alexander Larsson says:

    Thats the current cairo pdf generator, work is going on to make that better.

  4. Ross says:

    Thought so, glad it’s being worked on.

  5. Petar says:

    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

  6. tbf says:

    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?

  7. Petar says:

    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…

  8. tbf says:

    @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. :-/

  9. You rock so much Alex! This piece of software is awesome and vastly improves the printing platform!

  10. Duncan says:

    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?

  11. Alexander Larsson says:

    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.