Gtk2::PrintOperation
- From: Jeffrey Ratcliffe <jeffrey ratcliffe gmail com>
- To: "gtk-perl-list gnome org List" <gtk-perl-list gnome org>
- Subject: Gtk2::PrintOperation
- Date: Thu, 5 Aug 2010 22:52:21 +0200
Users have been asking for a print option. I saw Gtk2::PrintOperation,
but precious little help on how to use it. I translated the GUADEC2006
tutorial:
my $op = Gtk2::PrintOperation->new;
$op->set_print_settings($print_settings)
if (defined $print_settings);
$op->set_n_pages(1);
$op->set_unit('mm');
$op->signal_connect( draw_page => sub {
my ($op, $context) = @_;
my $cr = $context->get_cairo_context;
# Draw a red rectangle, as wide as the paper (inside the margins)
$cr->set_source_rgb( 1.0, 0, 0 );
$cr->rectangle(0, 0, $context->get_width, 50);
$cr->fill;
# Draw path
$cr->set_source_rgb( 0, 0, 0 );
$cr->move_to( 90, 75 );
$cr->line_to( 60, 80 );
$cr->curve_to( 40, 70, 65, 65, 70, 60 );
$cr->set_line_join( 'round' );
$cr->set_line_width( 5 );
$cr->stroke;
} );
This works. However, try as I might, I am unable to put a bitmap of
any sort on the $cr. This is my (non-working) code. Any tips (maybe
the scaling?) welcome:
my $op = Gtk2::PrintOperation->new;
$op->set_print_settings($print_settings)
if (defined $print_settings);
$op->set_n_pages(1);
$op->set_unit('mm');
$op->signal_connect( draw_page => sub {
my ($op, $context) = @_;
my $cr = $context->get_cairo_context;
my $surface = Cairo::ImageSurface->create_from_png('my.png');
$cr->set_source_surface( $surface, 0, 0 );
} );
Regards
Jeff
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]