Re: A few quick questions about gtkprint



On Wed, 15 Apr 2009 10:24:13 +0100
Chris Vine <chris cvine freeserve co uk> wrote:

At the library user level, gtk-print doesn't convert to ps or pdf in
order to print. It uses cairo/pango-cairo to write each page to a
cairo context.  It becomes clearer if you look at the documentation
for GtkPrintOperation (including the "draw-page" signal) and
GtkPrintContext.  After the drawing of the document with cairo has
been completed, gtk-print will convert those pages to postscript
where unix (cups or lpr) rather than windows is the underlying print
system, but that is not for the user to do nor bother with.

Since you refer to sugar, you may be doing this in python.  The py-gtk
documentation is generally pretty good (better in some respects than
the C interface documentation) so look at gtk.PrintOperation and
gtk.PrintContext etc., which covers the same ground with some
mini-examples.

As it happens, if you are only interested in running your programs
under unix-like operating systems, you can print a pre-prepared
postscript document using GtkPrintUnixDialog and GtkPrintJob with the
gtk_print_job_set_source_file() function, but doing that would offer
less features. You could not for example select the pages to be
printed, nor scale it nor set the margins, and it is not really the
best way to do it. So it is best to stick to the high level
GtkPrintOperation/cairo interface in order to give users what they
expect.

Sorry, just to complete the picture, you can draw the pages of pdf files
to cairo surfaces for printing via GtkPrintOperation using the poppler
library, and similarly for postscript using libspectre, but I do not
think that is what you were thinking about.  However, if you are, look
at the evince source for examples.

Chris



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