http://qs321.pair.com?node_id=700052

renegadex has asked for the wisdom of the Perl Monks concerning the following question:

does anybody have an example on how to convert goocanvas drawings to a pixbuf? i saw an example on how to save to pdf. but it did not help.. i wanted to convert the rendered cairo context into an imagesurface then using pixbufloader i would convert it into pixbuf. then using pixbuf i can save it to jpeg. :D this is what i did..
sub write_pdf_clicked { print "Write PDF...\n"; my $surface = Cairo::ImageSurface->create("a8", 2100, 1500); my $cr = Cairo::Context->create($surface); $cr->translate(0, 0); $canvas->render($cr, undef, 1); $cr->show_page; #print $surface; my $pixbufloader = Gtk2::Gdk::PixbufLoader->new; $pixbufloader->write($surface); $pixbufloader->close; my $pixbuf = $pixbufloader->get_pixbuf; return 1; }