mst3000 has asked for the wisdom of the Perl Monks concerning the following question:
I found this code somewhere online (tried to find it in my history but I'm frazzled and can't find it right now)
Okay...it loads up the html file PERFECTLY. However, afterwards, the program begins churning out a PDF file that will fill the disk. Looking at the PDF file in a text editor, it's just blank page after blank page.#!/usr/bin/perl use strict; use warnings; use Glib qw(TRUE FALSE); use Gtk2 -init; use Gtk2::MozEmbed; Gtk2::MozEmbed -> set_profile_path($ENV{ HOME } . "/.mybrowser", "MyBrowser"); my $moz = Gtk2::MozEmbed -> new(); $moz -> load_url("file:///root/gtk/test.html"); my $window = Gtk2::Window -> new(); $window -> signal_connect( delete_event => sub { Gtk2 -> main_quit; return FALSE; }); $window -> set_title("MyBrowser"); $window -> set_default_size(600, 400); $window -> add($moz); $window -> show_all(); my $op = Gtk2::PrintOperation->new; $moz->signal_connect( net_stop => sub { print "Document start\n"; print "Create a PDF ...\n"; $op->set_export_filename ("test.pdf"); $op -> set_allow_async(FALSE); $op->run ("export", $window); }); $op->signal_connect( status_changed => sub{ print "status changé en " . $op->get_status . "\n"; if ($op->is_finished ){ print "PDF Done\n"; } }); Gtk2 -> main;
After doing some troubleshooting, I realized that if I do $op->run('export',undef); this results in exactly the same thing.
However, $window is definitely assigned. So, what is the problem with this? Google has been no help whatsoever, as I can find next to nothing usable concerning Gtk's PrintOperation
Any help would be VERY appreciated!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Gtk2::PrintOperation problem
by sam_bakki (Pilgrim) on Jan 28, 2012 at 13:05 UTC |