in reply to Re^2: Including a PDF in Perl/Tk
in thread Including a PDF in Perl/Tk
#!/usr/bin/perl -w use Tk; use strict; use Proc::Killfam; my $mw = MainWindow->new; my $pid; # global for killing viewer my $pdf = 'z.pdf'; my $button = $mw->Button(-text => 'Open PDF Viewer', -command => [\&xpdf_test, $pdf] )->pack; my $button1 = $mw->Button(-text => 'Close PDF Viewer', -command => \&xpdf_close )->pack; MainLoop(); sub xpdf_test { my $pdf = shift; $pid = fork; if ( $pid < 0 ) { die "Fork failed: $!\n" } elsif ( $pid == 0 ) { # forked code system ("xpdf -g '400x500+100+100' $pdf"); } } sub xpdf_close{ killfam 9, $pid; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Including a PDF in Perl/Tk
by Joe_ (Beadle) on Jun 26, 2012 at 19:15 UTC |