Some considerations about the canvas and printing



Hi,

About one year ago, I sent several messages concerning the possibility
of printing the canvas with just a call as
gnome_canvas_print (canvas, print_context);

My intention was to use such a mechanism to print the canvas in
GChemPaint (http://savannah.nongnu.org/projects/gchempaint). The cvs
version is almost complete.

I quickly understood that there was no chance that such a thng will be
included in the official canvas in a foreseable future since it would
add dependance on libgnomeprint which is not stable. So I decided to
import everything necessary from the canvas as a statically linked
library to my project. The situation is now the following:

- It works and use a GPrintable interface as suggested by Michael Meeks.
I add a special group supporting this interface on top of the items tree
and it calls the print method of the interface for its child when they
support it.

- Items supported are GnomeCanvasRange and all its descendents,
GnomeCanvasLine, GnomeCanvasText, GnomeCanvasRichText. I have also
written the code for images but I did not include it as it is not useful
for GChemPaint.

It does not support pagination since the application owning the canvas
is responsible for that.

For Texts, I hoped there will be a solution in libgnomeprint-2.4.x, but
as nothing was there, I had to write a helper function to print a
PangoLayout (some features are not supported and some fonts give bad
results).

My canvas version is built on top of the official canvas. For
GnomeCanvasText, I did not import anything, just derived a new class
with the GPrintable interface. For other items, the situation is not so
good, in particular, I had to import the whole shape code just because
the property "width_units" is a write only property...

I suppose that my solution might be helpful for others.

Best regards,

Jean




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]