Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Gtk2::PrintOperation problem

by mst3000 (Novice)
on Jan 26, 2012 at 06:30 UTC ( #950029=perlquestion: print w/ replies, xml ) Need Help??
mst3000 has asked for the wisdom of the Perl Monks concerning the following question:

Hopefully one of the Monks can help with this one...I'm under a deadline and can't get this working properly at all.

I found this code somewhere online (tried to find it in my history but I'm frazzled and can't find it right now)

#!/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;
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.

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!!

Comment on Gtk2::PrintOperation problem
Select or Download Code
Re: Gtk2::PrintOperation problem
by sam_bakki (Monk) on Jan 28, 2012 at 13:05 UTC

    Hi

    I also great fan of perl GTK2. But the perl Gtk2's documentation is not complete and not good to refer.

    Since, perl gtk2 maintains the APIs as close to its underlaying C APIs, we can just refer the PyGtk's documentation, which is really good and complete. Once you know about the API, you can then write it in perl

    Coming to your issue, try use, ,

     'GTK_PRINT_OPERATION_ACTION_EXPORT' instead of export

    you can read some info about this printoperation class here

    http://www.pygtk.org/docs/pygtk/class-gtkprintoperation.html#method-gt +kprintoperation--run http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/PrintOperation.html#enum +_Gtk2_PrintOpera

    i dont not have printer to try myself, I will try this code and update you.

    -Bakki http://code.google.com/p/saaral-soft-search-spider/ - A perl Gtk2 project

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://950029]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (15)
As of 2014-08-27 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (239 votes), past polls